Pregunta de entrevista de Microsoft

Based on dp and graphs