Simple BFS Solution with Explanation in Java
Intuition:\n- There are limited number of transformations.\n- Using BFS to iterate through all possible transformations.\n- Record the lexicographically smalles
Intuition:\n- There are limited number of transformations.\n- Using BFS to iterate through all possible transformations.\n- Record the lexicographically smallest.\n\n```java\nclass Solution {\n    public String findLexSmallestString(String s, int a, int b) {\n        Queue<String> queue = new ArrayDeque<>();\n        Set<String> visited = new HashSet<>();\n        queue.offer(s);\n        visited.add(s);\n        \n        String rst = s;\n        while (!queue.isEmpty()) {\n            String curr = queue.poll();\n            if (curr.compareTo(rst) < 0) {\n                rst = curr;\n            }\n            \n            String opA = performA(curr, a);\n            if (visited.add(opA)) {\n                queue.offer(opA);\n            }\n            \n            String opB = performB(curr, b);\n            if (visited.add(opB)) {\n                queue.offer(opB);\n            }\n        }\n        \n        return rst;\n    }\n    \n    private String performA(String s, int a) {\n        int n = s.length();\n        char[] chars = s.toCharArray();\n        for (int i = 0; i < n; i++) {\n            if (i % 2 == 1) {\n                chars[i] = (char)((chars[i] - \'0\' + a) % 10 + \'0\');\n            }\n        }\n        \n        return new String(chars);\n    }\n    \n    private String performB(String s, int b) {\n        int n = s.length();\n        return s.substring(n - b) + s.substring(0, n - b);\n    }\n}\n```
[]