Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- // insert test case string here
- string a = "(([()])))";
- int rounded_counter = 0;
- int squared_counter = 0;
- for(int i = 0; i < a.length(); i++)
- {
- if(a[i] == '(')
- rounded_counter += 1;
- else if(a[i] == ')')
- rounded_counter -= 1;
- else if(a[i] == '[')
- squared_counter += 1;
- else if(a[i] == ']')
- squared_counter -= 1;
- }
- if(rounded_counter == 0 && squared_counter == 0)
- cout << "Yes" << endl;
- else
- cout << "No" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement