Spring Hire Sale
Limited Time Deal: Unlock all premium questions for over 30% off
$10.42$7.08
08
:
04
:
50
:
26
Back to Dashboard
Wildcard Segment Counter
Hard
You are given a template string consisting only of the characters '0', '1', and '?', and a list of integers run_lengths.
A '?' in the template can be replaced by either '0' or '1'. After all replacements, the resulting binary string must have consecutive runs of '1's with lengths exactly matching run_lengths in order (with at least one '0' separating each run, and no extra '1's outside the runs). Count the number of distinct ways to replace all '?' characters so the resulting string satisfies this condition.
...