LC56 Merge Intervals

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]
Tags: Array Sort

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