Question: In C# solve the following problem Problem 8 Balanced Most recent open matches first close First open may wait until last close We want to

In C# solve the following problem

In C# solve the following problem Problem 8 Balanced Most recent open

Problem 8 Balanced Most recent open matches first close First open may wait until last close We want to write a program that takes a string of opening and closing parentheses and checks to see whether it's balanced. We have exactly two types of parentheses for this problem: round brackets: and square brackets: []). Assume that the string doesn't contain any other characters than these. This means no spaces, digits, letters, or other symbols. Balanced parentheses require that there are an equal number of opening and closing parentheses. It requires that every opening parenthesis be closed in the reverse order opened. For example, (1) is balanced, but (1) ] is not. It also requires that no closing parenthesis appears before an opening parenthesis. Input The file contains a positive integer n and a sequence of n strings of parentheses, one string per line. Each string is of length n, (2 sn 80). You may assume each string contains only parentheses of type () and (), and no other characters. Output Output each input string in the format below indicating whether or not it is balanced. Sample Input [] ([]) ((( ( 0])0 (((( )))) ) (0 (0) 0) (1) Output Corresponding to Sample Input () is balanced [] is balanced ([]) is balanced ([000](is balanced ((( ))) is not balanced ) ( is not balanced (O (O) () is balanced (0)] is not balanced

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!