Pergunta de entrevista da empresa Susquehanna International Group

usually graph and dp problem.