Write a function that checks if a given string of parentheses ((), {}, []) is balanced using a stack-based approach.
HardProblem Statement
Write a function that checks if a given string of parentheses ((), {}, []) is balanced using a stack-based approach.
Sample Input
"({[]})"Sample Output
true
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
package main
import "fmt"
func isBalanced(s string) bool {
// Your code here
}
func main() {
fmt.Println(isBalanced("({[]})")) // Expected Output: true
fmt.Println(isBalanced("({[})")) // Expected Output: false
}
Input
"({[]})"Expected Output
true