Code
The highlighted line runs next. The pill shows the live values in the running call.
Cost
Work done so far, and how the two solutions compare
String
Small numbers are positions in the original string
The highlighted line runs next. The pill shows the live values in the running call.
Work done so far, and how the two solutions compare
Small numbers are positions in the original string
Keyboard: ← → step, Space play or pause. 1 to 24 characters from ( ) [ ] { }. Try "deep nesting" with Brute force to see one layer disappear per round (the O(n²) case), then with Stack to see one pass.