1585. Check If String Is Transformable With Substring Sort Operations
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
from collections import defaultdict

class Solution:
    def isTransformable(self, s: str, t: str) -> bool:
        digits_positions = defaultdict(list)
        for i in range(len(s)-1, -1, -1):
            digits_positions[int(s[i])].append(i)
        
        for char in t:
            digit = int(char)
            if not digits_positions[digit]:
                return False
            position = digits_positions[digit].pop()
            for smaller_digit in range(digit):
                if digits_positions[smaller_digit] and digits_positions[smaller_digit][-1] < position:
                    return False
        return True

```
['Python3']