Python | DFS
Code\n\nclass Solution:\n    def findLexSmallestString(self, s: str, a: int, b: int) -> str:\n        res = s\n        seen = set()\n        q = [s]\n        wh
# Code\n```\nclass Solution:\n    def findLexSmallestString(self, s: str, a: int, b: int) -> str:\n        res = s\n        seen = set()\n        q = [s]\n        while q:\n            cur = q.pop()\n            res = min(res, cur)\n            nxt = [int(d) for d in cur]\n            for i in range(1, len(nxt), 2):\n                nxt[i] = (nxt[i] + a) % 10\n            rot = cur[-b:] + cur[:-b]\n            for x in [rot, "".join(str(i) for i in nxt)]:\n                if x not in seen:\n                    seen.add(x)\n                    q.append(x)\n        return res\n```
['Python3']