Given an n x n matrix where each row and column is sorted in ascending order, find the kth smallest element in the sorted order. The solution should have a memory complexity better than O(n^2).
Constraints
n == matrix.length == matrix[i].length
1 <= n <= 300
-10^9 <= matrix[i][j] <= 10^9
All rows and columns of matrix are sorted in non-decreasing order.