Greedy
154 / 170GreedyLesson 8 of 9About 49 min
When a choice is genuinely undecidable now, track every outcome it could lead to at once.
After two wildcards, the possible counts of open brackets are listed by working out every interpretation. Type the two lines it prints.
from itertools import product counts = set()for choices in product("(),", repeat=2): # each wildcard: open, close, nothing open_count = 0 for choice in choices: open_count += 1 if choice == "(" else (-1 if choice == ")" else 0) counts.add(open_count) print(sorted(counts))print("gaps in that range:", [n for n in range(min(counts), max(counts) + 1) if n not in counts])Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.