100.00% of c++|| 2 approach ||Using Map and sorting || optimise space
1st approach using only sorting function\n\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) { \n        vector<string>v;\n        \n        for(int
**1st approach using only sorting function**\n```\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) { \n        vector<string>v;\n        \n        for(int i=0;i<=30;i++){\n            int p = pow(2 , i);\n            v.push_back(to_string(p));\n        }\n        \n        for(int i=0;i<=30;i++){\n            sort(v[i].begin() , v[i].end());\n        }\n        \n        string s = to_string(n);\n        sort(s.begin() , s.end());\n        \n        for(int i=0;i<=30;i++){\n            if(v[i]==s) return true;\n        }\n        return false;\n    }\n};   \n```\n\n**2nd approach using map**\n```\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) { \n\n         int x = pow(10 , 9);\n         map<int ,vector<int>>word;\n         for(int i=1;i<=x;i=i*2){\n             int k =i;\n             vector<int>v(10 , 0);\n             while(k){\n                 int l = k%10;\n                 v[l]++;\n                 k=k/10;\n             }\n             word[i]=v;\n         }\n        \n         vector<int> v(10 , 0);\n         while(n){\n             int l = n%10;\n             v[l]++;\n             n=n/10;\n         }\n        \n         for(int i=1;i<=x;i=i*2){\n            \n             vector<int> m=word[i];\n             bool flag=0;\n             for(int j=0;j<=9;j++){\n                if(v[j]!=m[j]){\n                    flag=1;\n                }\n             }\n             if(flag==0){\n                 return 1;\n             }\n         }\n         return 0; \n    }\n};   \n```\n\n**If you found this solution helpful a upvote is highly appreciated**
['C', 'Sorting']