Pergunta de entrevista da empresa Google

Graphs and DP mostly with some twists