Kth Smallest in Sorted Matrix

00:00
HardArrayBinary SearchHeap
AmazonGoogle

Find kth smallest element in n×n matrix where each row and column is sorted.

Examples

Input → [[1,5,9],[10,11,13],[12,13,15]], k=8
Output → 13
Input → [[-5]], k=1
Output → -5
Input → [[1,2],[1,3]], k=2
Output → 1