← All problemsSign in

Correct Bracket Sequence

CodeChefRating 2765Open on judge ↗

A string consisting only of parentheses ('(' and ')') is called a bracket sequence. Some bracket sequence are called correct bracket sequences(CBS). More formally: - Empty string is a CBS. - If S is a CBS, then (S) is also a CBS. - If S and T are CBS, then ST (concatenation of S and T) is also a CBS. A 'good' CBS is a sequence where the first (N/2) characters are '(' and the next (N/2) characte

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start