class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: # time O(NlgN) space O(1) # step1: edge case no intervals if not intervals: return intervals # step2: sort in order of end , initialize end and res intervals.sort(key = lambda k: k[0]) res = [] for ele in intervals: if not...
[Read More]
LC253 Meeting Rooms II
Solution1: (optimal) Sort + Min-heap (Priority Queue)
[Read More]
LC404 Sum of Left Leavess
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: # time O(N) space O(1) # step1 initialize total, check if root empty, if...
[Read More]
LC211 Design Add and Search Words Data Structure
```python
class TrieNode:
def init(self):
self.children = {}
self.isEnd = False
class WordDictionary:
[Read More]
LC1032 Stream of Characters
```python
class StreamChecker:
[Read More]