Pregunta de entrevista de Susquehanna International Group

usually graph and dp problem.