Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. // insert test case string here
  9. string a = "(([()])))";
  10. int rounded_counter = 0;
  11. int squared_counter = 0;
  12.  
  13. for(int i = 0; i < a.length(); i++)
  14. {
  15. if(a[i] == '(')
  16. rounded_counter += 1;
  17. else if(a[i] == ')')
  18. rounded_counter -= 1;
  19. else if(a[i] == '[')
  20. squared_counter += 1;
  21. else if(a[i] == ']')
  22. squared_counter -= 1;
  23. }
  24. if(rounded_counter == 0 && squared_counter == 0)
  25. cout << "Yes" << endl;
  26. else
  27. cout << "No" << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement