Skip to content

Commit

Permalink
Time: 0 ms (100.00%), Space: 5.9 MB (92.26%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedasad236 committed Feb 13, 2023
1 parent f3baf4c commit b48072a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public:
int countOdds(int low, int high) {
long long range = high - low + 1;
if(range & 1) {
range--;
return (range / 2 + (high & 1 ? 1 : 0));
} else {
return range / 2;
}
}
};

0 comments on commit b48072a

Please sign in to comment.