Advertisement
jakaria_hossain

codeforce - string transformation

May 28th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. string s;
  6. cin>>s;
  7. int len=s.size();
  8. char ch='a';
  9. for(int i=0;i<len;i++)
  10. {
  11. if(ch>=s[i])
  12. {
  13. s[i]=ch;
  14. ch++;
  15.  
  16. if(ch>122)
  17. break;
  18. }
  19. }
  20. if(ch==123)cout<<s<<endl;
  21. else printf("-1\n");
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement