Solution 1: use timestamp(as string/tuple format) as key to hash, linear look for recorded logs
```python
class LogSystem:
[Read More]
Lc1539
```python class Solution: def findKthPositive(self, arr: List[int], k: int) -> int: “”” some restrains: 1. sorted(strickly increasing) array, ideally always start with 1 2. “”” # time O(N) space O(1) n = len(arr) if arr[0] != 1: if k -(arr[0]-1) <= 0: return k else: k = k - (arr[0]-1)...
[Read More]
LC381. Insert Delete GetRandom O(1) - Duplicates allowed
```python class RandomizedCollection: “”” 1. hashmap to store val_ idx set mapping; list to store duplicable values 2. when remove, find any idx with val in the list, swap with last element, update swapped remove last in the list, pop 3. get random, to get random choice in the list...
[Read More]
LC1348. Tweet Counts Per Frequency
Bruteforce Solution
```python
class TweetCounts:
def init(self):
self.user = collections.defaultdict(list)
def recordTweet(self, tweetName: str, time: int) -> None:
self.user[tweetName].append(time)
[Read More]
LC666. Path Sum IV
```python class Solution: def pathSum(self, nums: List[int]) -> int: d = {} for x in nums: key = x // 10 # level_pos val = x % 10 d[key] = val def dfs(lp,psum,d): if d.get(lp) == None: return 0 # can't use not d.get(lp), since hashmap can have value ==...
[Read More]