Kth Smallest Number in Multiplication Table
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
An m x n multiplication table has the value i * j in row i, column j (both **1-indexed**), so it holds m * n numbers, many of them repeated.
Given m, n, and k, return the k-th smallest number in the table, counting duplicates (i.e. the value at position k of the sorted list of all m * n entries, 1-indexed).
Building and sorting the table is too slow for the largest inputs; aim for about O(m * log(m * n)).
Examples
Constraints
- `1 <= m, n <= 3 * 10^4`
- `1 <= k <= m * n`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.