Kth Smallest Number in Multiplication Table

Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed).

Given three integers m, n, and k, return the k^th smallest element in the m x n multiplication table.

Example 1
Inputm = 3, n = 3, k = 5
Output3
The 5^th smallest number is 3.
Example 2
Inputm = 2, n = 3, k = 6
Output6
The 6^th smallest number is 6.

Constraints

  • 1 <= m, n <= 3 * 10^4
  • 1 <= k <= m * n

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate