#668
Kth Smallest Number in Multiplication Table
candidate master · 1320 · lc hard +32 · verified · 53.8% accepted · 2,269 likes · top 45%
Description
Consider an m x n multiplication table, which forms an integer matrix mat where mat[i][j] == i * j using 1-based indexing.
Given integers m, n, and k, find and return the kth smallest value among all entries in this multiplication table.
Example 1:
Input: m = 3, n = 3, k = 5
Output: 3
Explanation: The 5th smallest number is 3.
Example 2:
Input: m = 2, n = 3, k = 6
Output: 6
Explanation: The 6th smallest number is 6.
Code
1
2
3