Skip to content

Commit 1f8a4b1

Browse files
authored
Create minimum-bit-flips-to-convert-number.cpp
1 parent 9946f93 commit 1f8a4b1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Time: O(logn)
2+
// Space: O(1)
3+
4+
// bit manipulation
5+
class Solution {
6+
public:
7+
int minBitFlips(int start, int goal) {
8+
return __builtin_popcount(start ^ goal);
9+
}
10+
};

0 commit comments

Comments
 (0)