Amazon Interview Question

They asked me a question on graphs and should be simple