1120. Maximum Average Subtree

```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 maximumAverageSubtree(self, root: TreeNode) -> float: # time O(N) space O(H) “”” avg = sum(subtree) / # node, use post order traversal to get subtree... [Read More]
Tags: Tree

1007. Minimum Domino Rotations For Equal Row

```python from collections import Counter class Solution: def minDominoRotations(self, A: List[int], B: List[int]) -> int: # time O(A+B) space O(1) cntA,cntB,same =Counter(A),Counter(B),Counter() if len(A) != len(B): return -1 for a,b in zip(A,B): if a == b : same[a] += 1 for v in range(1,7): if cntA[v] + cntB[v] - same[v]... [Read More]
Tags: Array Greedy