SHARE
TWEET

codeforce - string transformation

jakaria_hossain May 28th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top