Example 1 · empty
- Arguments
- text
""
- Expected return
true
Test data
- Input
{"text":""}- Expected output
true
func BalancedDelimiters(text string) boolExamples use {"text": "..."}.
The runner calls your functions directly; you do not need to parse JSON.
""
true
{"text":""}true
"{[()]}"true
{"text":"{[()]}"}true
"([)]"
false
{"text":"([)]"}false
"()[]{}"true
{"text":"()[]{}"}true
The stack stores open groups in nesting order, with the most recently opened group on top. A closing delimiter must close that group before any enclosing group. Matching and popping enforces both kind and order; a remaining opening delimiter at EOF proves an unclosed group.
O(n) time and O(n) worst-case auxiliary space for n delimiter characters. Each opening is pushed once and popped at most once.
Checking execution availability…
View inputs and expected outputs. Examples do not run your code.