✅ [C++] || Easy, Simple & Clean Solution | BFS | DFS
\nclass Solution {\npublic:\n    string findLexSmallestString(string s, int a, int b) {\n        string ans = s;\n        bfs(ans, a, b);\n        // unordered_
```\nclass Solution {\npublic:\n    string findLexSmallestString(string s, int a, int b) {\n        string ans = s;\n        bfs(ans, a, b);\n        // unordered_set<string> st;\n        // dfs(s, a, b, st, ans);\n        return ans;\n    }\n    void bfs(string &ans, int a, int b){\n        queue<string> Q;\n        unordered_set<string> st;\n        \n        Q.push(ans);\n        while(!Q.empty()){\n            int sz = Q.size();\n            for(int i = 0; i < sz; i++){\n                string s = Q.front();\n                Q.pop();\n                if(st.find(s) != st.end())\n                    continue;\n                st.insert(s);\n                Q.push(add(s,a));\n                Q.push(rotate(s,b));\n                ans = min(ans, s);\n            }\n        }\n    }\n    void dfs(string s, int a, int b, unordered_set<string> &st, string &ans){\n        if(st.find(s) != st.end())\n            return;\n        st.insert(s);\n        ans = min(ans, s);\n        dfs(add(s, a), a, b, st, ans);\n        dfs(rotate(s, b), a, b, st, ans);\n    }\n    string add(string s, int a){\n        string ans = s;\n        for(int i = 0; i < s.size(); i++){\n            if(i % 2)\n                ans[i] = (s[i] - \'0\' + a) % 10 + \'0\';\n        }\n        return ans;\n    }\n    string rotate(string s, int b){\n        int n = s.size();\n        string ans = "";\n        ans += s.substr(n - b);\n        ans += s.substr(0, n - b);\n        return ans;\n    }\n};\n```
[]