让枚举最小字典序, 由于string可以直接比较字符串的字典序。
① 让奇数位字符加a ,用到函数updata 具体看下面实现,加上’0’就可以转换为string类型!!!很神奇。
②后移b位可以用函数substr实现,具体看代码。
class Solution {
public:
void updata(char& s, int a)
{
s = '0' + (s - '0' + a)%10;
}
string findLexSmallestString(string s, int a, int b) {
string ans = s;
int n = s.size();