[Java] BFS
\nclass Solution {\n    public String findLexSmallestString(String s, int a, int b) {\n        Queue<String> queue = new LinkedList<>();\n        HashSet<String
```\nclass Solution {\n    public String findLexSmallestString(String s, int a, int b) {\n        Queue<String> queue = new LinkedList<>();\n        HashSet<String> seen = new HashSet<>();\n        queue.add(s);\n        String fin = s;\n\n        while (!queue.isEmpty()) {\n            String curr = queue.poll();\n            if (seen.contains(curr)) {\n                continue;\n            }\n\n            if (curr.compareTo(fin) < 0) {\n                fin = curr;\n            };\n\n            seen.add(curr);\n\n            String re = Rotate(curr, b);\n            queue.add(re);\n\n            String re1 = add (curr, a);\n            queue.add(re1);\n        }\n        return fin;\n    }\n\n    public String Rotate(String s, int b) {\n        return s.substring(b) + s.substring(0, b);\n    }\n\n    public String add (String s, int a) {\n        StringBuilder str = new StringBuilder();\n        for (int i = 0; i < s.length(); i++) {\n            if (i % 2 != 0) {\n                int k = (s.charAt(i) - \'0\');\n                k += a;\n                if (k == 10) {k = 0;} else if (k > 0) {k = k % 10;}\n                str.append(k);\n            }\n            else {\n                str.append(s.charAt(i));\n            }\n        }\n        return str.toString();\n    }\n}\n```
[]