Moody's interview question

Coin selection puzzle, SQL Joins