[C++] 100% faster iterative solution
\nclass Solution {\npublic:\n    string minn;\n    int a, b, n;\n    string gen(int i, string &res) { // new string after b-rightshift at i\n        return res.
```\nclass Solution {\npublic:\n    string minn;\n    int a, b, n;\n    string gen(int i, string &res) { // new string after b-rightshift at i\n        return res.substr(i, n - i) + res.substr(0, i);\n    }\n    int getStride(string &res, int start) { // get best stride\n        int x = res[start] - \'0\', d = 10, stride = 0, cur;\n        do{\n            x = (x + a)%10;\n            stride++;\n            if(x < d)\n                d = x, cur = stride;\n        } while( x != res[start] - \'0\');\n        return cur;\n    }\n    void tfrm(string &res, int start) { // add \'a\' stride times\n        int x, stride = getStride(res, start);\n        for(int i = start; i < n; i+=2) \n            res[i] = (res[i] - \'0\' + a*stride)%10 + \'0\';\n    }\n    void shift(int ind, string res) { // shifted string beginning at i\n        res = gen(ind, res);\n        tfrm(res, 1);\n        minn = min(minn, res);\n        if(b%2 == 0) \n            return;\n        tfrm(res, 0);\n        minn = min(minn, res);\n        tfrm(res, 1);\n        minn = min(minn, res);\n        \n    }\n    string findLexSmallestString(string s, int A, int B) {\n        a = A, b = B, n = s.size(), minn = s;\n        int x = 0;\n        do{\n            shift(x, s);\n            x = (x + n - b)%n;\n        }while(x != 0);\n        return minn;\n    }\n};\n```
[]