Kth smallest in matrix
Your task
Given an n x n matrix where each row and each column is sorted in ascending order, return the k-th smallest element in the matrix (in overall sorted order). 1 <= n <= 300 and 1 <= k <= n*n. Aim to beat O(n^2 log n).
Examples
kth_smallest_matrix(matrix: list[list[int]], k: int) -> intExample 1
Input
kth_smallest_matrix([[1, 5, 9], [10, 11, 13], [12, 13, 15]], 8)Output
13