LeetcodeFull List1-500378. Kth Smallest Element in a Sorted MatrixOn this page378. Kth Smallest Element in a Sorted MatrixPython Min Heap Time: O(N*M) Space: O(N*M) import heapqclass Solution: def kthSmallest(self, matrix: List[List[int]], k: int) -> int: heap = [] for row in matrix: for num in row: heapq.heappush(heap, num) return heapq.nsmallest(k, heap)[-1]