This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/submissions/1109638560/ | |
#include <stdio.h> | |
unsigned int minimumOneBitOperations(unsigned int n) { | |
uint32_t result = 0; | |
while (n) { | |
result ^= n; | |
n >>= 1; | |
} | |
return result; |