Practice · 7 of 9
Mixed B2 (even lengths)
CHALLENGE
Difficulty: advanced+25 XP
**Bài toán.** Given a bracket sequence with some characters replaced by '?', compute the minimum number of single-character replacements making the sequence balanced ('?' may become either bracket; any character other than '(' counts as ')' and vice versa — replacements may change existing brackets too). **Constraints:** 2 ≤ |s| ≤ 200000; |s| is even; s contains only '(' ')' '?'. **Input:** one line: s. **Output:** one integer — the minimum replacements.
Press Submit to check your solution.
Back to lesson: Practice: Mixed Sets A/B/C — Topics Hidden