```python class Solution: def countRestrictedPaths(self, n: int, edges: List[List[int]]) -> int: “”” 1. build graph + dijkstra get min distance from node x to node n with map 2. start from nth node to ith node distance to make dis(i+1) < dis(i) ===> distance from current node to last node...
[Read More]
1272. Remove Interval
Naive solution
```python
[Read More]
1576. Replace All ?'s to Avoid Consecutive Repeating Characters
class Solution: def modifyString(self, s: str) -> str: """tc O(N) sc O(N) """ n = len(s) res = [] for i in range(n): x= y = '?' if s[i] == '?': if i > 0: l = i-1 x = res[l] if i+1 < n: r = i +1 y...
[Read More]
1539. Kth Missing Positive Number
class Solution: def findKthPositive(self, arr: List[int], k: int) -> int: """ tc O(N) sc O(1) 1. set target tail value 2. loop arr, check if curren meet expected val 3. if no, get diff and compare with k 4. if k not reaching 0, continue the loop, otherwise return the...
[Read More]
732. My Calendar III
Solution1: Sweep Line ```python “”” main idea: boundry count (dict + sort ) each event, store its start and end time, and mark change delta among whole timeline iterate whole timeline, based on mark to udpate accumutive intersection cnt compare with global max cnt “”” class MyCalendarThree: def init(self): self.timeline...
[Read More]