Meesho Interview Question

Leetcode hard problem on graph and dp.