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.
stack depth
Track nesting as a walk
An opening bracket steps inward; its matching close returns to the prior depth.
open -> depth + 1close -> depth - 1stack top -> matching opener
- 1
Scan openers
Scan left to right; push each opening position and increase depth. - 2
Match closers
On a closing bracket, pop its matching opening and measure the enclosed span. - 3
Record maxima
Keep the greatest depth and span with their first starting positions.
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.