EASY [ PYTHON ] CODE👍
\n# Approach\n Describe your approach to solving the problem. \n\nThis is a solution to a problem that involves finding the lexicographically smallest string af
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nThis is a solution to a problem that involves finding the lexicographically smallest string after performing a series of operations on an input string. Let\'s break it down:\n\n1. The function `findLexSmallestString` takes three parameters:\n   - `s`: the input string\n   - `a`: an integer used for addition operation\n   - `b`: an integer used for rotation operation\n\n2. It initializes a set `arr` and a list `li` with the input string `s`.\n\n3. The main loop continues while `li` is not empty:\n\n   a. It pops the first string from `li`.\n   \n   b. It performs the first operation: adding `a` to every odd-indexed digit (modulo 10).\n      - It converts the string to a list of characters.\n      - For each odd index, it adds `a` to the digit and takes the last digit of the result.\n   \n   c. After the addition operation, if the resulting string is new (not in `arr`), it\'s added to both `arr` and `li`.\n   \n   d. Then it performs the second operation: rotating the string by `b` positions to the right.\n   \n   e. Again, if this rotated string is new, it\'s added to both `arr` and `li`.\n\n4. This process continues, generating all possible strings that can be created through these operations.\n\n5. Finally, it returns the lexicographically smallest string from all generated strings using `min(arr)`.\n\nThe key idea is to explore all possible strings that can be generated through these operations (addition to odd-indexed digits and rotation) and then find the smallest among them.\n\nThe use of a set (`arr`) ensures that each unique string is only processed once, preventing infinite loops and improving efficiency. The list (`li`) acts as a queue to manage the strings that still need to be processed.\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def findLexSmallestString(self, s: str, a: int, b: int) -> str:\n        arr = set()\n        arr.add(s)\n        li = []\n        li.append(s)\n        while li :\n            s = li.pop(0)\n            l = list(s)\n            for j in range(len(s)) :\n                if j % 2 != 0 :\n                    num = str(int(l[j]) + a) \n                    l[j] = num[-1]\n            s ="".join(l)\n            if s not in arr :\n                arr.add(s)\n                li.append(s)\n            s = s[-b:] + s[:-b]\n            print(s , "r")\n            if s not in arr :\n                arr.add(s)\n                li.append(s)\n        return min(arr)       \n\n```
['Python3']