Amazon interview question

Questions from dynamic programming and string