Amazon Interview Question

1) One programming question on graph