Merge Intervals LeetCode solution in Python
1class Solution:2def merge(self, A: List[List[int]]) -> List[List[int]]:3# sort array wrt its 0'th index4A.sort(key=lambda x: x[0])5i = 06while i < (len(A) - 1):7if A[i][1] >= A[i + 1][0]:8A[i][1] = max(A[i + 1][1], A[i][1])9A.pop(i + 1)10else:11i += 112return A