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]

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]
Tags: Design

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]
Tags: Tree