Amazon interview question

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