Python 3 solution with explanation
Intuition\nIf we have an s[i] in i index we see from what index to what index it can be moved i.e s[i] can be placed at any index in range lower_index, upper_in
# Intuition\nIf we have an s[i] in i index we see from what index to what index it can be moved i.e s[i] can be placed at any index in range **lower_index, upper_index** in s\n\n# Approach\nthe intuition is to check where each digit at index i in string s can go upto \nfor example let s = \'3158581\' here 5 at index 2 can\'t go any further before and cant go beyond index 3, so its limits are [2,3] (including 2 and 3) similarly for 5 at index 4 it is [3,5]. we can get this range by calculating count of all numbers before index i that are less than and equal to s[i] and we can get upper limit by len(s)-1-c where c is count of all numbers at index greater than i that are grater than or equal to s[i].\nnow ranges of 5 in above number is [[2,3],[3,5]] we sort this array on first number if equal then second number\nnow get the all indexes of 5 in t (target) in sorted order.\nex: [2,5] \nNote: if len(ranges[5])!=len(indexes[5]) then return False as 5 has diff frequency in s and t\nnow for i in indexes of 5 in t whether check range is satisfying or not.\nfor examples ranges(5) in s:[[2,3],[3,5]] and indexes is [2,5] (both arrays should be sorted) (if diff length return False)\nfor each iteration in length try whether the index is in range or not\nex:\n    **for i==0:**\n        ind = 2 and range = [2,3]\n        here ind is in range go to next iteration\n    **for i==1:**\n        ind = 5 and range = [3,5]\n        here ind is in range go to next iteration\n    **as we can attain all indexes 5 is done. similarly do this to all numbers from 0 to 10**\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfrom collections import defaultdict\nclass Solution:\n    def isTransformable(self, s: str, t: str) -> bool:\n        #here love is the array that holds ranges of digits from 0 to 9 (len(love)==10)\n        #here see is the array that holds indexes of all the digits in t (len(see)==10)\n\n        total = [0]*10\n        #Total array is the frequency of each digit from 0 to 9 in suffix i.e after index i\n        temp = [0]*10\n        #Temp array is the frequency of each digit from 0 to 9 is prefix i.e before i\n        for i in s:\n            total[int(i)]+=1\n        love = [[] for i in range(10)]\n        ##Love is range \n        for i in s:\n            ko = int(i)\n            lo = sum(temp[:ko+1]) ##Getting lower_value\n            temp[ko] += 1 #Updating temp\n            total[ko] -= 1 #Updating total\n            up = sum(total[ko:])\n            up = len(s)-up-1 #getting upper_index\n            love[ko].append([lo,up])\n        for i in range(len(love)):\n            love[i].sort() ##Sorting ranges\n        see = [[] for i in range(10)]\n        for i in range(len(t)):\n            ii = int(t[i])\n            see[ii].append(i)\n        # for i in range(10):see[i].sort() #No need to sort indexes they are already sorted\n        def checkNum(num): #Function that checkes whether indexes are attainable or not for a digit num\n            if len(see[num])!=len(love[num]):return False\n            for i in range(len(see[num])):\n                if see[num][i] not in range(love[num][i][0],love[num][i][1]+1):return False\n            return True\n        for i in range(10):\n            if not checkNum(i):return False\n        return True\n```
['Python3']