Problems > More Even Digits than Odd > Editorial

More Even Digits than Odd — Solution & Editorial

Back to the Problem

Digit DP with prefix difference; carry tight and leading-zero flags.

Complexity: O(digits · states)

Watch out: Leading zeros must not be counted as even digits — keep the balance at 0 through them.