BharatPe Interview Question

based on trees, graphs and dynamic programming