Skip to main content
PreparationZone Logo
PreparationZone
Back to Coding

Coding · Hard · Pro

Kth smallest element in a row-wise and column-wise sorted matrix

CodingBinary SearchStaff
Model answerPreview

Approach

  • Binary search the value space between matrix min and max.
  • For candidate value, count how many elements are ≤ value (walk from top-right).
  • Adjust lo/hi until the kth smallest…