Samsung Electronics Interview Question

Question related to graph and puzzels.