C++ Easy to understand brute force with helper functions, with comments
Keep a map to check if a pattern has been visited.\n2. Apply add and rotate on each string.\n3. Keep track of lexicographically shortest string encountered unti
1. Keep a map to check if a pattern has been visited.\n2. Apply add and rotate on each string.\n3. Keep track of lexicographically shortest string encountered until now between original string, added string and rotated string.\n4. Resursively add and rotate, until any of the patterns repeat themselves.\n\n```\nclass Solution {\npublic:\n    string add(string s, int a){\n        int i;\n        string r;\n        for(i = 0; i < s.size(); i++) {\n            if(i % 2 == 0) {\n                r += s[i];\n            }else{\n                r += \'0\' +  ( ( (s[i] - \'0\') + a ) % 10);\n            }\n        }\n        return r;\n    }\n    \n    string rotate(string s, int b){\n        return s.substr(b, s.size() - b) + s.substr(0, b);\n    }\n    \n    string F(string s, int a, int b, string m, map <string, bool> &M)\n    {\n        if(M.find(s) != M.end()) {\n            return m;\n        }\n        M[s] = true;\n\n        string ad = add(s, a);\n        string ro = rotate(s, b);\n         \n        if (ro < ad && ro < s) {\n            m = ro;\n        }\n        else if (ad < s && ad < ro) {\n            m = ad;\n        }else {\n            m = s;\n        }\n        \n        string retr = F(ro, a, b, m, M);\n        string reta = F(ad, a, b , m , M);\n       \n        return min(retr, reta);\n    }\n    \n    string findLexSmallestString(string s, int a, int b) {\n        string mx; // minimum string encountered until now\n        map <string, bool> M; // a map of any string that has been visited until now\n        return F(s, a, b, mx, M);\n    }\n};\n```\n\n**If you liked the solution, Kindly upvote, thank you**!
['C']