C++ | STRING | BFS
PLEASE UPVOTE IF U LIKE THE SOLUTION.\n\n\nclass Solution {\n    \n    //create the add function //operation:1\n    string add(string s,int a)\n    {\n        f
**PLEASE UPVOTE IF U LIKE THE SOLUTION.**\n\n```\nclass Solution {\n    \n    //create the add function //operation:1\n    string add(string s,int a)\n    {\n        for(int i=0;i<s.length();i++)\n        {\n            if(i&1)\n            {\n                s[i]=(s[i]-\'0\'+a)%10+\'0\';\n            }\n        }\n        return s;\n    }\n    \n    //create the rotate function //operation:2\n    string rotate(string s,int b)\n    {\n        string res=s.substr(s.length()-b)+s.substr(0,s.length()-b);\n       return res;\n    }\n    \npublic:\n    string findLexSmallestString(string s, int a, int b) \n    {\n        //we perform a simple BFS and check from\n        //all possible conversions from string s\n        //the lexicographically smallest string possible using any permutations \n        //of operation 1 and 2\n        unordered_set<string>vis;\n        queue<string>q;\n        vis.insert(s);\n        q.push(s);\n        string res=s;\n        \n        while(q.size())\n        {\n            string curr=q.front();\n            q.pop();\n            \n            string s1=add(curr,a);\n            string s2=rotate(curr,b);\n            \n            //we do the minimum check here\n            res=min(res,curr);\n            \n            if(!vis.count(s1))\n            {\n                vis.insert(s1);\n                q.push(s1);\n            }\n            \n            if(!vis.count(s2))\n            {\n                vis.insert(s2);\n                q.push(s2);\n            }\n        }\n        \n        return res;\n    }\n};\n```
['String', 'Breadth-First Search']