Skip to content

Commit

Permalink
Create 2220. Minimum Bit Flips to Convert Number (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Sep 11, 2024
2 parents ae1dccf + e50dc56 commit 32f8aa7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 2220. Minimum Bit Flips to Convert Number
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public:
int minBitFlips(int start, int goal) {
int x = start ^ goal;
int count = 0;
while (x > 0) {
count += x & 1;
x >>= 1;
}
return count;
}
};

0 comments on commit 32f8aa7

Please sign in to comment.