BFS solution ```python 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 minDepth(self, root: TreeNode) -> int: if not root: return 0 q = collections.deque([(root,1)]) while q: node, level = q.popleft() if not node.left...
[Read More]
863. All Nodes Distance K in Binary Tree
```python
[Read More]
739. Daily Temperatures
```python “”” main idea is (monotonous stack) to loop through each element in the T, record with old temprature with stack(from old to most recent). compare current temperate with most recent temperature, if current is higher than most recent, get the difference with current and most recent, store into result...
[Read More]
Lc735
```python
[Read More]
364. Nested List Weight Sum II
time O(N) space O(H) Two pass ```python ””” This is the interface that allows for creating nested lists. You should not implement it, or speculate about its implementation ””” #class NestedInteger: def init(self, value=None): ””” If value is not specified, initializes an empty list. Otherwise initializes a single integer equal...
[Read More]