Binary Indexed Tree
\nclass Solution {\n    void update(int id,int val,vector<int> &BIT,int n){\n        while(id<=n){\n            BIT[id]+=val;\n            id+=id&(-id);\n      
```\nclass Solution {\n    void update(int id,int val,vector<int> &BIT,int n){\n        while(id<=n){\n            BIT[id]+=val;\n            id+=id&(-id);\n        }\n    }\n    \n    int get(int id,vector<int> &BIT){\n        int res=0;\n        while(id>0){\n            res+=BIT[id];\n            id-=id&(-id);\n        }\n        return res;\n    }\npublic:\n    bool isTransformable(string s, string t) {\n        vector<int>v[10];\n        int n =s.size();\n         vector<vector<int>>BIT(10,vector<int>(n+1,0));\n        \n        for(int i=n-1;i>=0;i--){\n         int val=s[i]-\'0\';\n            v[val].push_back(i);\n            update(i+1,1,BIT[val],n);\n        }\n        \n        for(int i=0;i<n;i++){\n            int val=t[i]-\'0\';\n            if(v[val].empty())\n                return false;\n            int id=v[val].back();\n            v[val].pop_back();\n            int count=0;\n            for(int j=0;j<val;j++){\n                count+=get(id,BIT[j]);\n            }\n            \n          \n            \n            if(count>0)\n                return false;\n            \n            update(id+1,-1,BIT[val],n);\n        }\n        \n    return true;\n       \n    }\n};\n```
[]