Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Kth Smallest In Multiplication Table

Medium Acceptance 75% Points 30

You are given two integers m and n representing the dimensions of a multiplication table, and an integer k. The multiplication table is formed such that the value at position (i, j) is equal to i × j. Your task is to return the kth smallest number in this multiplication table.

Examples
Example 1

Example 1

Input: m = 3, n = 3, k = 5

Output: 3

Explanation: The multiplication table is: 1 2 3 2 4 6 3 6 9 All elements in sorted order are [1,2,2,3,3,4,6,6,9]. The 5th smallest number is 3.

Example 2

Example 2

Input: m = 2, n = 3, k = 6

Output: 6

Explanation: The multiplication table is: 1 2 3 2 4 6 All elements in sorted order are [1,2,2,3,4,6]. The 6th smallest number is 6.

Example 3

Example 3

Input: m = 4, n = 5, k = 8

Output: 4

Explanation: The multiplication table is: 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 All elements in sorted order are [1,2,2,3,3,4,4,4,5,6,6,8,8,9,10,12,12,15,16,20]. The 8th smallest number is 4.

Constraints
  • 1 = m, n = 3 × 104
  • 1 = k = m × n
Topics
Binary Search
Companies
Amazon
Added 25 Jul 2026 75% acceptance
Ln 1, Col 1Sign in to save your code
3 3 5
3