Kth Smallest Element in a Sorted Matrix

Medium · Heap & Priority Queue · about 25 minutes

Asked at Google, Amazon, Meta, Microsoft, Uber.

Given an n × n matrix where every row and every column is sorted in ascending order, return the k-th smallest element (counting duplicates, so it's the k-th in sorted order, not the k-th distinct).

Related guides