Swap toward the rule
transcript
A greedy rule looks right on small examples. But looking right is not a proof. Interviewers want to hear why it holds. Here is the proof, in one move.
Take any best plan you can imagine. Swap two of its items to match the rule. If the plan is no worse, the rule is safe. Repeat that for each choice the rule makes.
You hold a hundred credits. The rule redeems the cheapest token. Suppose a best plan redeems a dearer token instead. Swap in the cheaper token that was left unused. Your credits stay higher, so nothing later breaks.
Redeeming the cheapest alone reaches a score of one. Now cash in the dearest token once as well. That gives back a point and buys many credits. Now the score reaches three.
In this game, a point can be given back. Giving it back buys many credits at once. Those credits pay for more cheap redemptions.
Swap a best plan toward the rule. Show that the plan is not worse. Then you can trust the greedy choice. Full breakdown in the lecture.