Uber Interview Question

To solve a question on Graph