Amazon interview question

graphs question like rotten oranges