Domanda di colloquio di Amazon

two coding questions, one for dynamic programming, one for greedy