155. Min Stack

Amazon’s - Min Stack

July 12, 2024 · 2 min · BeagleHQ

190. Reverse Bits

Amazon’s - Reverse Bits

July 12, 2024 · 2 min · BeagleHQ

191. Number Of One Bits

Problem Statement in English Approach This is a subset of this problem. Solution in Python class Solution: def hammingWeight(self, n: int) -> int: ans = 0 while n > 0: if n&1 > 0: ans+=1 n = n >> 1 return ans Complexity Time: $O(1)$ Since we only process $32$ bits at most. Space: $O(1)$ Since we only store an integer variable. And we are done.

July 12, 2024 · 1 min · BeagleHQ

338. Counting Bits

Amazon’s - Counting Bits

July 12, 2024 · 2 min · BeagleHQ

75. Sort Colors

Meta’s - Sort Colors

July 12, 2024 · 2 min · BeagleHQ