Part III: Matching Brackets (20 points)
Only symbols (.), (..), and ], and ((O and [(1((11 contain balanced brackets, while )]1 and ()) are unbalanced.
We need to identify the "left brackets" as ( and [ and the "right brackets" as ) and ].
Input a string s.
CSE 101 Spring 2018 Homework 3 Page
If the character is a left bracket, append the character to L.
Return the string "error" if the character is a right bracket and the rightmost element of L does not have a matching left bracket. Delete the rightmost element of L (because we have a match) if there is a matching left bracket.
If there is a mismatch, return L.
Hint: You can use a stack to keep track of the brackets.
Return brackets ll.
Return brackets (())(((()).
Return brackets ('a8EM).