BFS/unordered_set solution C++
\nclass Solution {\npublic:\n    string findLexSmallestString(string s, int a, int b) {\n        unordered_set<string> visited;\n        queue <string> que;\n  
```\nclass Solution {\npublic:\n    string findLexSmallestString(string s, int a, int b) {\n        unordered_set<string> visited;\n        queue <string> que;\n        que.push(s);\n        string ans = s;\n        visited.insert(s);\n        while(!que.empty()){\n            string frt = que.front();\n            if(ans> frt) ans = frt;\n            que.pop();\n            vector <string> tmp = both(frt,a,b);\n            if(visited.find(tmp[0]) == visited.end()){\n                visited.insert(tmp[0]);\n                que.push(tmp[0]);\n            }\n            if(visited.find(tmp[1]) == visited.end()){\n                visited.insert(tmp[1]);\n                que.push(tmp[1]);\n            }\n        }\n        return ans;\n    }\n    vector <string> both(string s,int &a,int &b){\n        vector <string> res (2,s);\n        for(int i =1; i < s.length(); i+=2){\n            int num = res[0][i]-\'0\';\n            num += a;\n            num %= 10;\n            res[0][i] = \'0\'+num;\n        }\n        res[1] = s.substr(s.length()-b,s.length())+s.substr(0,s.length()-b);\n        return res;\n    }\n};\n```
[]