Plus One
easyTime: O(n)Space: O(1)
Signals to notice
add one to number represented as arrayhandle carryright to left
Brute force first
Convert to number, add 1, convert back — fails for very large numbers. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
The key insight
Process right to left, handle carry. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
What must stay true
Carry propagates leftward; stop as soon as there's no carry. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Easy way to go wrong
Forgetting the case where all digits are 9 (999 → 1000) — need to prepend a 1. The fix is usually to return to the meaning of each move, not just the steps themselves.