Google Interview Question

It was related to dp on graph