Given a sorted matrix of integers A of size N x M and an integer B.
Each of the rows and columns of matrix A are sorted in ascending order, find the Bth smallest element in the matrix.
Return The Bth smallest element in the sorted order, not the Bth distinct element.
The first argument given is the integer matrix A. The second argument given is an integer B.
Return the Bth smallest element in the matrix.
1 <= N, M <= 500 1 <= A[i] <= 10^9 1 <= B <= N*M
Input 1: A = [ [9, 11, 15] [10, 15, 17] ] B = 6 Output 1: 17 Input 2: A = [ [5, 9, 11] [9, 11, 13] [10, 12, 15] [13, 14, 16] [16, 20, 21] ] B = 12 Output 2: 16
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.