Solved LeetCode program · 474 of 1,000
#0668 · Kth Smallest Number in Multiplication Table
Original English source
Keep a shared total of 0. Keep a shared rows of 0. Keep a shared columns of 0.
To count up to bound (a whole number). Set total to 0.
For every row from 1 to rows.
The full is bound divided by row. The take is full. If take is more than columns, set take to columns. Increase total by take.
Set rows to 3. Set columns to 3. The target is 5. The low is 1. The high is rows times columns.
Repeat while low is less than high.
The middle is low plus high. Set middle to middle divided by 2. Count up to middle. If total is at least target, set high to middle, otherwise set low to middle plus 1.
Show low.
Expected stdout
3