Question: Java: Braces Given a list of strings of bracket characters: the string of brackets is balanced under the following conditions: It is the empty string.

Java: Braces
Given a list of strings of bracket characters:
the string of brackets is balanced under the following conditions:
It is the empty string.
If strings a and
are balanced, then
is balanced.
If string a is balanced, then
(
a
)
and
(
a
)
are balanced.
Write a class that determines whether the brackets in each string are balanced and returns true if the string is balanced, or false if it is not.
Example
0
s
[
O
]
exhibits condition
2
above.
"
{
}
"
and
"
"
are balanced, so
"
{
}
(
0
)
"
is balanced.
Return true.
s
[
1
]
exhibits condition
3
above.
"
(
)
"
is balanced, so
"
{
(
)
}
"
is balanced. Return true.
s
[
2
]
exhibits condition
3
above.
"
(
)
"
is balanced, so
"
{
(
)
}
"
is balanced and
"
(
{
(
)
}
)
"
is balanced. Return true.
Test Results

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!