Pregunta de entrevista de Rakuten

DP and Graph questions, medium leetcode I guess