Segment Tree Solution. C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\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```\nclass Solution {\npublic:\n    int seg_tree[400001];\n    string s;\n    int built_tree(int node, int l, int r){\n        if (l == r) return seg_tree[node] = s[l]-\'0\';\n        int mid = (l+r)/2;\n        return seg_tree[node] = min(built_tree(2*node+1, l, mid), built_tree(2*node+2, mid+1, r));\n    }\n\n    int query(int node, int ql, int qr, int l, int r){\n        if (ql > r || qr < l) return 1e9;\n        if (ql<= l && qr >= r) return seg_tree[node];\n        int mid = (l+r)/2;\n        return min(query(2*node+1, ql, qr,l,  mid), query(2*node+2, ql, qr, mid+1, r));\n\n    }\n\n    int update(int node, int index, int l, int r){\n\n        if (l == r && l == index){\n            return seg_tree[node] = 1e9;\n        }\n        if (index < l || index > r) return 1e9;\n        int mid= (l+r)/2;\n        return seg_tree[node] = min(update(2*node+1, index,l,mid ), update(2*node+2, index, mid+1,r));\n    }\n    bool isTransformable(string s, string t) {\n       this->s =s;\n       built_tree(0, 0, s.size()-1);\n\n       deque<int> digits[10];\n       for(int i=0;i<s.size();i++){\n           int digit = s[i] - \'0\';\n           digits[digit].push_back(i);\n       }\n    //    cout << query(0, 2,3,0,s.size()-1) << endl;\n       for(int i=0,j=0;i<t.size();i++){\n           int digit = t[i]-\'0\';\n           if (digits[digit].empty()) return false;\n           int index = digits[digit].front();\n           s[index] = \'_\';\n           \n           digits[digit].pop_front();\n           int mn = query(0,j, index, 0, s.size()-1);\n        //    cout << "mn of i " << j << " and index " << index  <<" " <<mn << endl;\n           if (mn < digit) return false;\n           while(s[j] == \'_\') j++;\n           update(0,index,0,s.size()-1);\n       }\n       return true;\n    \n\n    }\n};\n```
['C++']