Short solution, O(1) space for 1585
The logic is to see if a digit in the target string is at all movable (or rather "bubleable") from where it is occuring in the source string. It is true if it i
The logic is to see if a digit in the target string is at all movable (or rather "bubleable") from where it is occuring in the source string. It is true if it is smaller than all the digits preceding it. For example, we start with:\n```\n\ts = "84532"\n\t     ^^^\n\tt = "34852"\n         ^\n```\nWe compare 3 with 8, 4, 5 in s. They must be less than 3. We then adjust the strings by taking 3 out.\n```\n\ts = "8452"\n\t     ^\n\tt = "4852"\n         ^\n```\nand continue.\n\nIf there are runs, we erase the runs and not digit by digit. This is to avoid TLE in test case 129. For example:\n```\n\ts = "8453333332"\n\tt = "3333334852"\n}\n```\nFew lines of code:\n```\n/* tktripathy */\nclass Solution {\npublic:\n    bool isTransformable(string s, string t) {\n        char *sp = (char *)s.c_str(), *osp = sp, *tp = (char *)t.c_str();\n        while (s.size()) {\n            char *tsp = sp;\n            while (*tp != *tsp) { if (*tp >= *tsp) return false; tsp++; }\n            char c = *tp, *ttsp = tsp; int sz = 0;  /* take care of runs */\n            while (*tp == c && *ttsp == c) { tp++; ttsp++; sz++; }\n            s.erase(s.begin() + (tsp - osp), s.begin() + (tsp - osp) + sz);\n        }\n        return true;\n    }\n};\n```
[]