logseq_notes/pages/OJ notes/pages/Bit-Manipulation count true trick.md
2023-06-14 14:27:22 +08:00

34 lines
531 B
Markdown

# Bit-Manipulation count true trick
#### 2022-07-22 15:11
> ##### Algorithms:
>
> #algorithm #bit_manipulation
>
> ##### Data Structure:
>
> #DS #bitset
>
> ##### Difficulty:
>
> #CS_analysis #difficulty_easy
>
> ##### Additional tags:
##### Related problems:
### What is Bit-Manipulation count true trick?
(n & (n - 1))
### How does Bit-Manipulation count true trick work?
- #### validate if the number is power of 2
See [[Leetcode Power-of-Two]] Method 1
- #### Counting 1
See [[Leetcode Number-of-1-Bits]] Method2