Java: Braces
Given a list of strings of bracket characters: OQ the string of brackets is balanced under the following conditions:
It is the empty string.
If strings a and b are balanced, then ab 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[0] 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
2.Java:Brac
ALL
under the following con
1. is the empty string 2.if strings a and b are balanced then ab is balanced 3.if string a is balanced, then (a) and (a) are balanced
10 11 12 13
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.
class
Solution
Example o
[0000=s
s[0] exhibits condition 2 above. "0" and "0" are balanced, so "0" is balanced. Return true. s[1] exhibits condition 3 above. "0" is balanced, so "0" is balanced. Return true s[2] exhibits condition 3 above. "0" is balanced, so "0" is balanced and "0" is balanced. Return true.
Search
ASUS VivoBook