Java | Easy | BFS
\nclass Solution {\n    public String findLexSmallestString(String s, int a, int b) {\n        //BFS\n        Queue<String> q = new LinkedList<>();\n        q.a
```\nclass Solution {\n    public String findLexSmallestString(String s, int a, int b) {\n        //BFS\n        Queue<String> q = new LinkedList<>();\n        q.add(s);\n        Set<String> visited = new HashSet<>();\n        String ans = s;\n        while(q.size() > 0){\n            int count = q.size();\n            \n            while(count-- > 0){\n                String rem = q.remove();\n                //Compare strings lexicographically\n                if(ans.compareTo(rem) > 0){\n                    ans = rem;\n                }\n                //First operation\n                String ns = ""; //New String\n                for(int i = 0; i < rem.length();i++){\n                    if(i % 2 != 0){\n                        int d1 = rem.charAt(i) - \'0\';\n                        int d = d1 + a;\n                        d = d % 10;\n                        ns = ns + String.valueOf(d);                        \n                    }\n                    else{\n                        ns = ns + ""+rem.charAt(i);\n                    }\n                }\n                if(!visited.contains(ns)){\n                    q.add(ns);\n                    visited.add(ns);\n                }\n                //Second operation\n                ns = rightrotate(rem,b);\n                if(!visited.contains(ns)){\n                    q.add(ns);\n                    visited.add(ns);\n                }\n                \n            }\n        }\n        return ans;\n    }\n     String rightrotate(String str, int d){       \n            d = str.length() - d;\n            String ans = str.substring(d) + str.substring(0, d);\n            return ans;\n    }\n \n}\n```
[]