Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
2
Indexable
#include<bits/stdc++.h>
using namespace std ;
#define int long long 

 string smallestString(string s) {
         int n = s.size(); 
         if(s[0]=='a'){
             string x ="";
             x.push_back(s[0]);
             int i=1;
             while(s[i]!='a'&& i<n){
                 int t= s[i];
                 char m = char(t-1);
               x.push_back(m);
                 i++;
             }
              if(n-(i)>0 and  i< n ){
             string t= s.substr(i,n-(i));
             x+=t;
              }
             return x ;
             }
        else {
             string x ="";
            
             int i=0;
             while(s[i]!='a'&& i<n){
             int t= s[i];
                 char m = (t-1);
               x.push_back(m);
             }
            if(n-(i) >0 and i<n){
             string t= s.substr(i,n-(i));
             x+=t;
            }
              return x ;
            
             }
            
            
            
            
        }

int32_t main(){
  string s ;
  cin>>s ;
  cout<< smallestString(s);

  return 0;

}