Problems > All Digits at Least Five > Editorial

All Digits at Least Five — Solution & Editorial

Back to the Problem

Digit DP with prefix difference and tight/leading flags.

Complexity: O(digits · states)

Watch out: Leading zeros are exempt, but the first REAL digit must be 5-9.