Google interview question

Question on Graphs of medium difficulty level