Clara interview question

Glass Balls Algorithm Question