Advertisement
Falak_Ahmed_Shakib

strig erase

Sep 18th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. string str;
  5. cin>>str;
  6. int pos1,pos2;
  7. pos1=str.find("AB");
  8.  
  9. if(pos1!=-1)
  10. {
  11. str.erase(str.begin()+pos1,str.begin()+pos1+2);
  12.  
  13. pos2=str.find("BA");
  14. if(pos2!=-1)cout<<"YES";
  15. else cout<<"NO";
  16. }
  17. else
  18. cout<<"NO";
  19.  
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement