C++ - Using DFS & Both
\nclass Solution {\npublic:\n    string res;\n    string add(string s, int a)\n    {\n        for(int i=0;i<s.size();i++)\n            if(i%2) s[i] = ((s[i]-\'0
```\nclass Solution {\npublic:\n    string res;\n    string add(string s, int a)\n    {\n        for(int i=0;i<s.size();i++)\n            if(i%2) s[i] = ((s[i]-\'0\'+a)%10) + \'0\';\n        return s;\n    }\n    string rotate(string s, int b)\n    {\n        int n = s.size();\n        string temp = s.substr(n-b);\n        temp += s.substr(0, n-b);\n        return temp;\n    }\n    void dfs(string s, int a, int b, set<string> &v)\n    {\n        if(v.find(s) != v.end()) return;\n        v.insert(s);\n        res = min(res, s);\n        dfs(add(s, a), a, b, v);\n        dfs(rotate(s, b), a, b, v);\n    }\n    string findLexSmallestString(string s, int a, int b) \n    {\n        res = s;\n        set<string> v;\n        /*queue<string> q; //BFS CODE START\n        q.push(s);\n        while(!q.empty()) \n        {\n            string temp = q.front(); q.pop();\n            if(v.find(temp) != v.end()) continue;\n            v.insert(temp);\n            res = min(res, temp);\n            q.push(add(temp, a));\n            q.push(rotate(temp, b));\n        }*/ //BFS CODE END\n        dfs(s, a, b, v);\n        return res;\n    }\n};\n```
[]