Problems > Candles from Stubs > Editorial

Candles from Stubs — Solution & Editorial

Back to the Problem

Simulate in bulk: burn all, convert stubs to new candles, carry the remainder — each round divides by K, so O(log) rounds.

Complexity: O(1) or O(log)