We have an m×n matrix in which all rows are sorted in ascending order and all elements are distinct. We want to find the k-th smallest element in this matrix.
A= 3*4 =
[ 1 5 6 60
0 4 8 50
3 9 15 90]
K=7---> 8
There is an O(m(logm+logn)) algorithm for doing this!
We can think as union of all these rows (Each of them was pre-sroted) and find kth element amnog the union of all rows.
anyone has any idea or logic about it?