1625. Lexicographically Smallest String After Applying Operations.cpp
Code\n\nclass Solution {\npublic:\n    string AddOperation(string s, int a)\n    {\n        for(int i=1;i<s.length();i+=2)\n            s[i] = (s[i]-\'0\'+a)%10
**Code**\n```\nclass Solution {\npublic:\n    string AddOperation(string s, int a)\n    {\n        for(int i=1;i<s.length();i+=2)\n            s[i] = (s[i]-\'0\'+a)%10 + \'0\';\n        \n        return s;\n    }\n    string RotateOperation(string s, int b)\n    {\n        int left = s.length()-b;\n        \n        string str = s.substr(left,b) + s.substr(0,left);        \n        return str;\n    }    \n    string findLexSmallestString(string s, int a, int b) {\n        unordered_map<string,bool>visited;        \n        queue<string>Q;        \n        string result = "";        \n        Q.push(s);\n        visited[s] = true;        \n        string curr;        \n        while(!Q.empty())\n        {\n            curr = Q.front();\n            Q.pop();\n            if(result.empty() || lexicographical_compare(curr.begin(),curr.end(),result.begin(),result.end()))\n                result = curr;\n            string addString = AddOperation(curr,a);\n            string rotateString = RotateOperation(curr,b);\n            if(visited.count(addString)==0)\n            {\n                visited[addString] = true;\n                Q.push(addString);\n            }\n            if(visited.count(rotateString)==0)\n            {\n                visited[rotateString] = true;\n                Q.push(rotateString);\n            }\n        }        \n        return result;\n    }\n};\n```
['C']