![Given a list of strings of bracket characters: 00, the string of brackets is balanced under the following conditions: 1. It i](https://media.cheggcdn.com/study/18a/18a08133-bc39-464a-990b-b6ea39f80426/image.png)
![Example 1 S = TOC. O, C ALL s[0] rarr 2.0 is an unbalanced string due to the open C. Return false. s(1) rarr 2. (O) is](https://media.cheggcdn.com/study/dd2/dd2e8b14-5635-49b9-8570-61d21858d753/image.png)
![Each string consists only of the characters (. ). (and). - Each string has fewer than 50 characters. ALI Input Format for Cus](https://media.cheggcdn.com/study/56f/56f58f4a-8ee7-41dc-93a2-5823da5461bf/image.png)
![Sample Case o Sample Input o STDIN 2 Function 00 + s = [00), ({0), [(] ({0}) {}( 3 Sample Output 0 5 true true false 6](https://media.cheggcdn.com/study/452/452a7791-7d14-410e-9d56-6ddb29ec1826/image.png)
![Autocomplete Disabled 1 > import java.util.*; ... 4 5 // Write your code here. DO NOT use an access modifier in your class de](https://media.cheggcdn.com/study/2c2/2c24fc0f-dba5-44ee-8af2-2b4f9813c1a6/image.png)
Given a list of strings of bracket characters: 00, the string of brackets is balanced under the following conditions: 1. It is the empty string. 2. If strings a and bare balanced, then ab is balanced. 3. 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 balance false if it is not. Example 0 S = ["00", "{0}", "({0})" ] s[0] exhibits condition 2 above."0" and "0" are balanced, so "00" is balanced. Return true. s[1] exhibits condition 3 above. "O" 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. Example 1 S = ["(", "0", "(", "H") s[O] rarr 2. "O" is an unbalanced string due to the open "C". Return false. s[l) rarr 2. "(0)" is an unbalanced string due to ")" before "[" has been closed. Return false. s[2] rarr 2. "(C, is an unbalanced string because neither "(" is closed. Return false. Example 1 S = TOC. "O", "C" ALL s[0] rarr 2.0 is an unbalanced string due to the open "C". Return false. s(1) rarr 2. (O)" is an unbalanced string due to ")" before "{" has been closed. Return false. s[2] rarr 2. (C, is an unbalanced string because neither "(" is closed. Return false. s[2] rarr 2. "H" is an unbalanced string because ")" comes before a "t" and because the final "{" is not closed. Retur Function Description The provided code contains the declaration for a class named Solution with a main method that does the followi 3 • Creates a Parser object. • Reads an unknown number of strings from stdin. • Passes each string as an argument to the Parser object's isBalanced method and prints value returned by the metho line. Complete the function an isBalanced in the editor below. isBalanced has the following parameter(s): string s: a string of characters to check for balance Returns : bool: a boolean that denotes whether the string is balanced: true if the string is balanced, or false if it is not Each string consists only of the characters (. ). (and). - Each string has fewer than 50 characters. ALI Input Format for Custom Testing Input from stdin will be processed as follows and passed to your Parser.isBalanced method. 1 Each line contains a string to parse. 2 Sample Case 0 Sample Input 0 ???? STDIN Function {}() + s = ['00', '({0}', '{}('] ({0}) {}( 5 6 Sample Output 0 true true false ation 0 Sample Case o Sample Input o STDIN 2 Function 00 + s = ['00)', '({0)', '[('] ({0}) {}( 3 Sample Output 0 5 true true false 6 Explanation 0 2. '00' contains two adjacent balanced strings, 'l 'and 'O' so return true. 3. (CO}}' contains a balanced string ' Onested inside another balanced string, 'f', nested inside another balanced Return true. 2. ' contains a balanced string '/', followed by an unbalanced string '(. Return false. - wa EE DE 6 Autocomplete Disabled 1 > import java.util.*; ... 4 5 // Write your code here. DO NOT use an access modifier in your class declaration. 6 7 v class Solution { 8 9 public static void main(String[] args) { 10 Parser parser = new Parser(); 11 12 Scanner in = new Scanner(System.in); 13 14 while (in.hasNext()) { 15 System.out.println(parser.isBalanced (in.next()); } 16 in.close(); 17 18 19 20 21 } } I Line: 4 col Submit Code Run 12:30