Skip to main content
LeetCode 668, Hard. Topics: Math, Binary Search. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 30 parametrized pytest cases, and a playground notebook:

Problem

Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed). Given three integers m, n, and k, return the kth smallest element in the m x n multiplication table.

Examples

Example 1
Example 2

Constraints

  • 1 <= m, n <= 3 * 10^4
  • 1 <= k <= m * n

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026