Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 32bbfca

Browse files
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)

AltStyle によって変換されたページ (->オリジナル) /