Python 3   ||   12 lines, recursion,  dfs   ||   T/S: 90% / 20%
\nHere\'s the plan:\n\n- We determine the set of all possible states ofsunder the two transformations.\n\n- We return the lexicographic minimum of that set.\n\n
\nHere\'s the plan:\n\n- We determine the set of all possible states of`s`under the two transformations.\n\n- We return the lexicographic minimum of that set.\n```\nclass Solution:\n       def findLexSmallestString(self, s: str, a: int, b: int) -> str:\n\n        def dfs(s: str) -> str:\n\n            if s in seen: return\n\n            seen.add(s)\n            res, odd =\'\', True\n\n            for ch in s:\n                odd^= True\n                res+= d[ch] if odd else ch\n    \n            dfs(res)\n            dfs(s[b: ] + s[ :b])\n\n\n        d, seen = {ch:str((int(ch) + a) % 10\n                    ) for ch in digits}, set()\n\n        dfs(s)\n\n        return min(seen)\n```\n[https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations/submissions/1279671804/](https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations/submissions/1279671804/)\n\nI could be wrong, but I think that time complexity is *O*(2^*N*) and space complexity is *O*(2^*N*), in which *N* ~ `len(s)`.\n
['Python3']