Skip to content

Instantly share code, notes, and snippets.

@statulr
Last active November 30, 2023 16:05
Show Gist options
  • Save statulr/c3205c2ec873f777b913b18768542ebd to your computer and use it in GitHub Desktop.
Save statulr/c3205c2ec873f777b913b18768542ebd to your computer and use it in GitHub Desktop.
leetcode2148 (Faster than 100%)
//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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment