Skip to content

Commit 66ac2ae

Browse files
authored
Update Count Odd Numbers in an Interval Range.java
1 parent 2d83108 commit 66ac2ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Solution {
22
public int countOdds(int low, int high) {
3-
return (high + 1) / 2 - low / 2;
3+
return (high - low) / 2 + (low % 2 != 0 || high % 2 != 0 ? 1 : 0);
44
}
55
}

0 commit comments

Comments
 (0)