O(10*n) => O(n) Python Solution by counting smaller and bigger number for all digits
For S Count all bigger and smaller number for all digits\n2. Now after transformation count of bigger number cannot be greater and count of smaller number canno
1. For S Count all bigger and smaller number for all digits\n2. Now after transformation count of bigger number cannot be greater and count of smaller number cannot be smaller than S \n\n```\nfrom collections import defaultdict\nclass Solution:\n    def isTransformable(self, s: str, t: str) -> bool:\n        # count bigger and smaller number so far (from left side)\n        count_big_sofar_s = {}\n        count_small_sofar_s = {}\n        count = defaultdict(int)\n        for i, d in enumerate(s):\n            count[d] += 1\n            count_big_sofar_s[(d, count[d])] = (sum(count[str(j)] for j in range(int(d) + 1, 10)) , i )\n            count_small_sofar_s[(d, count[d])] = (sum(count[str(j)] for j in range(0, int(d))) , i )\n        \n        # making sure target char freq is same as source \n        for d in t:\n            count[d] -= 1\n            if count[d] < 0:\n                return False\n            \n        for i, d in enumerate(t):\n            count[d] += 1\n            count_big_sofar_t = sum(count[str(j)] for j in range(int(d) + 1, 10))\n            count_small_sofar_t = sum(count[str(j)] for j in range(0, int(d)))\n\n            big_so_far_s, index = count_big_sofar_s[(d, count[d])]\n            small_so_far_s, index = count_small_sofar_s[(d, count[d])]\n            \n            \n            if count_big_sofar_t > big_so_far_s or count_small_sofar_t < small_so_far_s:\n                    return False\n        return True\n        \n            \n        \n```
['Greedy', 'Python']