[C++] Clean (with explanation)
We need to consider all possible combinations - rotation by b and addition by a\n- The constraints are sufficient to use recursion\n- For each string, perform o
- We need to consider all possible combinations - rotation by b and addition by a\n- The constraints are sufficient to use recursion\n- For each string, perform operation (1), then recurse, then perform operation (2)\n- Remember seen values in a mem map, so as to not process them again (memoization)\n\n```\nclass Solution {\npublic:\n    int a, b;\n    string ret;\n    map<string, bool> mem;\n    void go(string s) {\n        if(mem.count(s)) return;\n        mem[s] = true;\n        ret = min(ret, s);\n        int i, n = s.size();\n        for(i=1; i<n; i+=2) {\n            int nw = ((s[i] - \'0\') + a) % 10;\n            s[i] = (char)(\'0\' + nw);\n        }\n        go(s);\n        rotate(s.rbegin(), s.rbegin() + b, s.rend());\n        go(s);\n    }\n    string findLexSmallestString(string s, int _a, int _b) {\n        a = _a;\n        b = _b;\n        ret = s;\n        go(s);\n        return ret;\n    }\n};\n```
[]