File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 384
384
| 1507 | [ Reformat Date] ( https://leetcode.com/problems/reformat-date ) | [ ![ Java] ( assets/java.png )] ( src/ReformatDate.java ) | |
385
385
| 1512 | [ Number of Good Pairs] ( https://leetcode.com/problems/number-of-good-pairs ) | [ ![ Java] ( assets/java.png )] ( src/NumberOfGoodPairs.java ) | |
386
386
| 1518 | [ Water Bottles] ( https://leetcode.com/problems/water-bottles ) | [ ![ Java] ( assets/java.png )] ( src/WaterBottles.java ) | |
387
- | 1523 | [ Count Odd Numbers In Interval Range] ( https://leetcode.com/problems/count-odd-numbers-in-an-interval-range ) | | |
387
+ | 1523 | [ Count Odd Numbers In Interval Range] ( https://leetcode.com/problems/count-odd-numbers-in-an-interval-range ) | [ ![ Java ] ( assets/java.png )] ( src/CountOddNumbersInIntervalRange.java ) | |
388
388
| 1528 | [ Shuffle Strings] ( https://leetcode.com/problems/shuffle-string ) | | |
389
389
| 1534 | [ Count Good Triplets] ( https://leetcode.com/problems/count-good-triplets ) | | |
390
390
| 1539 | [ Kth Missing Positive Number] ( https://leetcode.com/problems/kth-missing-positive-number ) | | |
Original file line number Diff line number Diff line change
1
+ public class CountOddNumbersInIntervalRange {
2
+ public int countOdds (int low , int high ) {
3
+ final int count = high - low + 1 ;
4
+ if ((count & 1 ) == 0 ) return count / 2 ;
5
+ return count / 2 + (low & 1 );
6
+ }
7
+ }
You can’t perform that action at this time.
0 commit comments