Count Odd Numbers in an Interval Range LeetCode solution in Java

1
class Solution {
2
public int countOdds(int low, int high) {
3
if (low % 2 == 0 && high % 2 == 0) {
4
return (high - low) / 2;
5
}
6
return (high - low) / 2 + 1;
7
}
8
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0