Kth Number in the Times Table
A times table has rows rows and cols columns. The cell in row r and column c, both counted from 1, holds r * c.
Return the kth smallest number in the table. A number that appears in several cells is counted once per cell.
Example 1
rows 3
cols 3
k 7
returns 6
In order the table reads 1, 2, 2, 3, 3, 4, 6, 6, 9. The seventh number is 6.
Example 2
rows 2
cols 5
k 6
returns 4
In order the table reads 1, 2, 2, 3, 4, 4, 5, 6, 8, 10. The sixth number is 4.
Constraints
1 <= rows <= 10001 <= cols <= 10**61 <= k <= rows * cols
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.