Problems > All Digits Even > Editorial

All Digits Even — Solution & Editorial

Back to the Problem

Digit DP with prefix difference and tight/leading flags.

Complexity: O(digits · states)

Watch out: Leading zeros are fine; the first real digit must be a non-zero even digit (2,4,6,8), which the tight/leading logic handles.