Samsung Electronics interview question

problem on graphs