STMicroelectronics interview question

candle puzzle, basic java