The Cursed Substring — Solution & Editorial
Digit DP tracking (previous-digit-is-1, already-found-13, tight). It is often easier to count those WITHOUT '13' and subtract, but tracking a 'has13' flag directly works too.
Complexity: O(digits · states)
Digit DP tracking (previous-digit-is-1, already-found-13, tight). It is often easier to count those WITHOUT '13' and subtract, but tracking a 'has13' flag directly works too.
Complexity: O(digits · states)