Amazon Interview Question

Live coding question on graph