Problems > Counting the Carries > Editorial

Counting the Carries — Solution & Editorial

Back to the Problem

Simulate the column addition, propagating the carry — note a carry can trigger the next carry (999 + 1).

Complexity: O(digits)

Watch out: 9 + 0 + carry = 10 — incoming carries create outgoing ones; 999+1 has three carries.