Kth Smallest Number in Multiplication Table

Try to solve the Kth Smallest Number in Multiplication Table problem.

Statement

You are given a multiplication table of size m×\timesn, where each element at position mat[i][j] is calculated as i×ji \times j (with 1-based indexing).

Your task is to find the kthk^{th} smallest element in this table, given the m, n, and k values.

Constraints:

  • 1≤1 \leq m, n ≤3×104\leq 3 \times 10^4

  • 1≤1 \leq k ≤\leq m ×\timesn

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.