Given three integers `m`, `n`, and `k`, consider the m x n multiplication table where the entry at row i, column j (both 1-indexed) is i * j. Return the k-th smallest number in this table. For example, with m = 3, n = 3, the table is: 1 2 3 2 4 6 3 6 9 Sorted: [1, 2, 2, 3, 3, 4, 6, 6, 9]. The 5th smallest number is 3.
Example 1
Input: m = 3, n = 3, k = 5
Output: 3
Explanation: The 3x3 multiplication table sorted is [1,2,2,3,3,4,6,6,9]. The 5th smallest is 3.
Example 2
Input: m = 2, n = 3, k = 6
Output: 6
Explanation: The 2 x 3 table is [1,2,3] and [2,4,6]. Sorted, that is 1, 2, 2, 3, 4, 6, so the 6th smallest is 6.
Example 3
Input: m = 1, n = 1, k = 1
Output: 1
Explanation: The 1 x 1 table contains only 1 * 1 = 1.
Binary search on the answer value x, counting how many entries in the table are <= x. The count for row i is min(x // i, n), summed over all rows.
Run checks all cases above. Submit evaluates all test cases.