> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/bit/bit-mask.md).

# Bit Mask

```
(num >> i) & 1 => num 二進制右移 i 位後, 跟 1 and, 取最右邊這位是不是1
```

```
mask < (1 << n)

1 << n means 2^n
so if n = 4 
-> 2^4 = 32

usually, use in loop all mask posibility
so 

n = 4
int i = 0; i < (1 << n); i++
-> means
int i = 0; i < 32; i++

```
