Pregunta de entrevista de Amazon

Questions from dynamic programming and string