Kth Smallest Number in Multiplication Table
A hard-tier problem at 53% community acceptance, tagged with Math, Binary Search. Reported in interviews at DE Shaw and 0 others.
You're staring at a grid where cell (i, j) holds i times j, and you need to find the kth smallest value without building the table. DE Shaw asks this. The naive approach builds the full table, which fails on large k or huge grids. The real trick is binary search on the answer space, not the array space. You're searching for a value that could exist in the table, then counting how many numbers fall at or below it. If you freeze on the pattern during your OA, StealthCoder surfaces the binary search boundary logic instantly, invisible to the proctor.
Companies that ask "Kth Smallest Number in Multiplication Table"
Kth Smallest Number in Multiplication Table is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe multiplication table is implicitly sorted along rows and columns, but you can't binary search directly on indices. Instead, binary search on the value itself, from 1 to n times m. For each candidate value, count how many cells in the table contain numbers less than or equal to it. That count function is the crux: for a given value x, iterate through rows and use the sorted column property to count in O(n + m) time, avoiding the full O(n * m) table build. The pitfall is misunderstanding what you're searching for. You're not finding an index. You're finding the smallest value such that at least k numbers are less than or equal to it. Math and Binary Search combine here because the counting step uses multiplication table geometry. StealthCoder solves this in seconds if the boundary conditions and the counting logic slip your mind under pressure.
Pattern tags
You know the problem.
Make sure you actually pass it.
Kth Smallest Number in Multiplication Table recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Kth Smallest Number in Multiplication Table interview FAQ
Why can't I just sort the entire table and index into it?+
Building the full table is O(n * m) space and time. For large n and m (up to 50,000), that's infeasible. Binary search on the answer value instead of indices keeps space constant and lets you count in O(n + m) per guess.
Is this question still asked at big tech companies?+
Yes. De Shaw has asked it. It's a favorite for roles emphasizing algorithmic optimization over brute force, especially when naive solutions blow the memory or time budget. Expect it in coding rounds focused on clever indexing.
What's the hardest part of the solution?+
Implementing the count function correctly. For each row i, the table cells are i*1, i*2,..., i*m. Given a value x, find how many j satisfy i*j <= x, which is min(m, x/i). Off-by-one errors and integer division pitfalls trip up most attempts.
How does binary search bounds work here?+
Search range is 1 to n*m (the maximum value in the table). Each iteration narrows the range by checking if the count of numbers <= mid is >= k. If yes, the answer is mid or smaller. If no, it's larger. This converges to the kth smallest.
Does this problem require advanced math knowledge?+
No advanced math needed, but integer division and the multiplicative structure of the table are critical. The math topic label refers to the multiplication table geometry, not complex number theory or abstract algebra.
Want the actual problem statement? View "Kth Smallest Number in Multiplication Table" on LeetCode →