Skip to content

Commit

Permalink
Create 2220. Minimum Bit Flips to Convert Number
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Sep 11, 2024
1 parent ae1dccf commit e50dc56
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 e50dc56

Please sign in to comment.