Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Given an integer array and a pattern string containing characters '0', '1', and '?', determine the number of valid string combinations that can be formed by replacing each '?' in the pattern with either '0' or '1'.

The array arr specifies the exact lengths of consecutive '1' segments that must appear in the string. For example:

Test Cases
Input
Output
Expected