File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 123
123
| 459 | [ Repeated Substring Pattern] ( https://leetcode.com/problems/repeated-substring-pattern ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RepeatedSubstringPattern.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/repeated_substring_pattern.py ) |
124
124
| 461 | [ Hamming Distance] ( https://leetcode.com/problems/hamming-distance ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/HammingDistance.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/hamming_distance.py ) |
125
125
| 463 | [ Island Perimeter] ( https://leetcode.com/problems/island-perimeter ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/IslandPerimeter.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/island_perimeter.py ) |
126
- | 475 | [ Heaters] ( https://leetcode.com/problems/heaters ) | Easy | |
127
- | 476 | [ Number Complement] ( https://leetcode.com/problems/number-complement ) | Easy | |
126
+ | 475 | [ Heaters] ( https://leetcode.com/problems/heaters ) | Medium | |
127
+ | 476 | [ Number Complement] ( https://leetcode.com/problems/number-complement ) | Easy | [ ![ Java ] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/NumberComplement.java ) |
128
128
| 482 | [ License Key Formatting] ( https://leetcode.com/problems/license-key-formatting ) | Easy | |
129
129
| 485 | [ Max Consecutive Ones] ( https://leetcode.com/problems/max-consecutive-ones ) | Easy | |
130
130
| 492 | [ Construct the Rectangle] ( https://leetcode.com/problems/construct-the-rectangle ) | Easy | |
Original file line number Diff line number Diff line change
1
+ public class NumberComplement {
2
+ public static int findComplement (int n ) {
3
+ int numberOfBits = (int ) (Math .floor (Math .log (n ) / Math .log (2 ))) + 1 ;
4
+ return ((1 << numberOfBits ) - 1 ) ^ n ;
5
+ }
6
+ }
You can’t perform that action at this time.
0 commit comments