Pregunta de entrevista de Pocket Gems

DP question, graph problem, and code evaluation.