Kth smallest element in a row-wise and column-wise sorted 2D array
Given an n x n matrix, every row and column is sorted in non-decreasing order. Given a number K where K lies in the range [1, n*n], find the Kth smallest element in the given 2D matrix.Example:Input: mat =[[10, 20, 30, 40], [15, 25, 35, 45], [24, 29, 37, 48], [32, 33, 39, 50]]K = 3Output: 20Explanat