Straight to the Point !
Are you landed to this page and rushing for the immediate solution in javascript. here you go !!
10, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89
On High level note, It worth to read in detail for a better understanding.
Table of Contents
- Problem Statement
- Constraints
- Expected
- Test Cases
- Foot Note
- Solution Intro
- Solutions
- Other Possible Questions
$desc$
Problem Statement
A bracket is any of the following characters: (, ), {, }, [, or ].
We consider two brackets to be matching if the first bracket is an open-bracket, e.g., (, {, or [, and the second bracket is a close-bracket of the same type. That means ( and ), [ and ], and { and } are the only pairs of matching brackets.
Furthermore, a sequence of brackets is said to be balanced if the following conditions are met:
- The sequence is empty, or
- The sequence is composed of two or more non-empty sequences, all of which are balanced, or
- The first and last brackets of the sequence are matching, and the portion of the sequence without the first and last elements is balanced.
You are given a string of brackets. Your task is to determine whether each sequence of brackets is balanced. If a string is balanced, return true, otherwise, return false
1bool isBalanced(String s)
Constraints
- Goes here
Expected
- Goes here
Test Cases
Below one is three nested
1s = {[()]}2output: true
Test Cases
1bool isBalanced(String s)
Foot Note
1bool isBalanced(String s)
Solution Intro
Lets see the list of approaches and their complexities.
Approach | Time Complexity | Space Complexity | |
---|---|---|---|
1 | Brute Force | O(n+m | O(m+n) |
2 | $Approach 1$ | O(n) | O(n) |
3 | $Approach 2$ | O(n) | O(n) |
4 | Time Optimized | O(n) | O(n) |
5 | Memory Optimized | O(n) | O(n) |
Solutions
With no further due, lets take a example of code solutions.
Brute Force
Description
1Code goes here...
$Approach-1$
Description
1Code goes here...
$Approach-2$
Description
1Code goes here...
$Time-Optimized$
Description
1Code goes here...
1Code goes here...