Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 32bbfca

Browse files
authored
Create 1523. Count Odd Numbers in an Interval Range
1 parent 95e85b5 commit 32bbfca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int countOdds(int low, int high) {
3+
int total = high - low +1;
4+
if(total%2==0){
5+
return total/2;
6+
}
7+
else{
8+
return total/2 + high%2;
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)