Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopbrackets · stack · sequence
The organizer’s problem statement is available at the official source link.
nested intervals
Measure alternating depth and typed matched spans
The sequence uses () and []; nested type changes determine alternating depth, while each bracket type has its own maximum matched-span length.
( [ ] ) -> nested( [ ) ] -> crossingstack enforces nesting
- 1
Match typed brackets
Push each opening bracket with its type and position; a close must match the stack top. - 2
Track alternating depth
Along nested pairs, count the maximum number of switches between bracket types. - 3
Track both span maxima
Record the largest matched () span and largest matched [] span separately.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.