Meta Interview Question

graph dp is main focus