Python - super simple 8 lines, no deque or other tricks
The idea is quite simple. String s can be transformed into t if it can be transformed through bubble-like operations, where we apply sorting only to two element
The idea is quite simple. String *s* can be transformed into *t* if it can be transformed through bubble-like operations, where we apply sorting only to two elements. This is true, because full sorting of a subarray can be achieved through bubble sorting. Think of moving one element to an earlier place in the string. We can move only if there are no smaller elements in front of it - if there are, the smaller oness will always be in front.\n\nNow, the final step is to check whether the order of elements in *t* is consistent with partial bubble sort of *s*. In other words, every next element of *t* needs to have only larger elements in front of it in *s*. \n\nOpportunities to speed up: use comparison of Counter from collections in order to compare whether the two strings have the same elements, populate list *locations* more intelligently in one pass instead of 10. \n\n```\nclass Solution:\n    def isTransformable(self, s: str, t: str) -> bool:\n        \n        s= s+"0123456789"\n        locations=[s.find(char) for char in "0123456789"] \n                \n        for char in t:\n            num=int(char)\n            if any(locations[num]>locations[i] for i in range(num)): return False\n            locations[num]=s.find(char, locations[num]+1)\n            \n        return True\n```
[]