Beginner friendly| Simple
Intuition\nDFS\n# Approach\nMake rotated string, and added string compare the minimum\n# Complexity\n- Time complexity:\n\n- Space complexity:\nO(n)\n\n# Code\n
# Intuition\nDFS\n# Approach\nMake rotated string, and added string compare the minimum\n# Complexity\n- Time complexity:\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    unordered_set<string> visited; \n    string ans; \n    string rotate(string s, int b){\n        reverse(s.begin(), s.end());\n        reverse(s.begin() + b, s.end());\n        reverse(s.begin() ,s.begin() + b);\n        return s; \n    }\n    string add(string s, int a){\n        for (int i=1; i<s.size(); i += 2) {\n            s[i] = \'0\' + (s[i]-\'0\'+a)%10;\n        }\n        return s;\n    }\n    void dfs(string s, int a, int b){\n        if(visited.find(s) != visited.end())return; \n        ans = min(ans, s);\n        visited.insert(s);\n        string rotated = rotate(s, b);\n        dfs(rotated, a, b);\n        string added = add(s, a);\n        dfs(added, a, b);\n    }\n    string findLexSmallestString(string s, int a, int b) {\n        ans = s;\n        dfs(s, a, b);\n        return ans;\n    }\n};\n```
['C++']