529. K-th Smallest Number in Multiplication Table

HardBinary SearchBinary Search on AnswerMath

Given the dimensions m and n of a multiplication table (where entry at row i, column j is i*j for 1 <= i <= m and 1 <= j <= n), return the k-th smallest value in the table. Use binary search on the value. Input: 'm, n, k'.

Input: 'm, n, k'.

Output: Integer — the k-th smallest table value.

Examples

Example 1
Input: 3, 3, 5
Output: 3
Explanation: Sorted table values; 5th is 3.
Example 2
Input: 2, 3, 6
Output: 6
Explanation: Largest entry.
Example 3
Input: 1, 1, 1
Output: 1
Explanation: Single entry.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →