LC191. Number of 1 Bits

mask ```python “”” initialize res, mask loop 32 bits, cnt cases any bit n& mask != 0, then move mask bit 1 forward return cnt cases “"”s class Solution: def hammingWeight(self, n: int) -> int: # time O(1) space O(1) mask = 1 res = 0 for i in range(32):... [Read More]

LC554. Brick Wall

```python class Solution: def leastBricks(self, wall: List[List[int]]) -> int: “”” tc O(NM) sc O(L) N: len of wall ; M: max len of each row ; L : number of unique accuemutive sum main idea: break least bricks means for each list, presum at each point freq is the most... [Read More]
Tags: HashTable