Question: Time limit: 500ms Memory limit: 256mb Description: You are given a string consisting of parentheses () and []. A string of this type is said

Time limit: 500ms Memory limit: 256mb Description: You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a) if it is the empty string (b) if A and B are correct, AB is correct, (c) if A is correct, (A) and [A] is correct. Write a program that takes a string of this type and check their correctness. Your program can assume that the maximum string length is 128. Tips: Try using stack to solve this problem. -------------------------Copy the following code, complete it and submit------------------------- /* I, , am submitting the assignment for an individual project. I declare that the assignment here submitted is original except for source material explicitly acknowledged, the piece of work, or a part of the piece of work has not been submitted for more than one purpose (i.e. to satisfy the requirements in two different courses) without declaration. I also acknowledge that I am aware of University policy and regulations on honesty in academic work, and of the disciplinary guidelines and procedures applicable to breaches of such policy and regulations, as contained in the University website http://www.cuhk.edu.hk/policy/academichonesty/. It is also understood that assignments without a properly signed declaration by the student concerned will not be graded by the teacher(s). */ #include  #define SN 200 int judge_string(char str[], int n) { // WRITE YOUR CODE HERE // CHECK WHETHER THIS STRING IS CORRECT } // DO NOT MODIFY THE CODE BELOW int main() { int n, i, result; char a[200]; scanf("%d", &n); scanf("%s", a); result = judge_string(a, n); if(result){ printf("Yes"); } else { printf("No"); } return 0; } -------------------------------------------End of Code------------------------------------------- Input: First line contains a non-negative integer N; The second line contains a, a string of N characters, a_0, a_1, ..., a_(N-1); 0 <= N < 128 Output: If the string is correct output Yes, otherwise output No. Sample Input 1: 8 ([()])() Sample Output 1: Yes Sample Input 2: 9 (([()]))) Sample Output 2: No 

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!