Index the table by the small number
transcript
Pick transfers under a fee cap. The cap is a billion. A table over the fee is huge.
A table over the fee needs a billion cells. But the scores are small. A hundred transfers score at most fifty each. So the scores add up to five thousand.
Index the table by the score. Store the least fee for each score. The fee becomes the value in the cell.
Go through the scores from the top. Stop at the first fee within the cap. That score is the answer.
A hundred transfers, five thousand scores. That is half a million steps. Fees add up to ten to the eleven, so use sixty-four bits.
Compare the limits of fee and score. Index the table by the small one. Store the large one in the cell.
Keep the plain table as a slow twin. Run both on tiny random inputs. Stop at the first difference.
Compare the limits. Index by the small one. Full breakdown in the lecture.