Untitled
unknown
plain_text
6 months ago
1.1 kB
1
Indexable
Never
#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; }