Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string arr;
- cin >> arr;
- int len=arr.size();
- bool k=true;
- for (int i=0; i<len; i++){
- if(arr[i]=='(' ){
- if (arr[i+1]=='}' or arr[i+1]==']'){
- k=false;
- break;
- }
- }
- else if (arr[i]=='{'){
- if (arr[i+1]==')' or arr[i+1]==']'){
- k=false;
- break;
- }
- }
- else if (arr[i]=='['){
- if (arr[i+1]==')' or arr[i+1]=='}'){
- k=false;
- break;
- }
- }
- else if (arr[i]=='{' and arr[i+1]==')' or arr[i+1]==']'){
- }
- }
- if (k==true){
- cout << "Yes";
- }
- else {
- cout << "No";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement