Robot Fruit interview question

the puzzle