This is an interview question.
Find the Kth smallest element in a matrix with sorted rows and columns. Is it correct that the Kth small
Above solution could not handle diagonal condition and can not be applied to below matrix
int arr2[][] = { { 1, 4, 7, 11, 15 }, { 2, 5, 8, 12, 19 }, { 3, 6, 9, 16, 22 }, { 10, 13, 14, 17, 24 }, { 18, 21, 23, 26, 30 } }
And k=5
Returning 7 whereas answer is 5