IBM interview question

coding round : greedy and graph