[C++] 0 ms, faster than 100.00%
C++:\n\nvector<string> arr = {"0112344778","011237","0122579",\n"012356789","0124","0134449","0145678","01466788","0248",\n"0368888","0469","1","112234778","112
**C++:**\n```\nvector<string> arr = {"0112344778","011237","0122579",\n"012356789","0124","0134449","0145678","01466788","0248",\n"0368888","0469","1","112234778","11266777","122446",\n"125","128","1289","13468","16","2","224588","23","23334455",\n"234455668","23678","256","35566","4","46","8"};\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) {\n       string s =  to_string(n);\n       sort(s.begin(),s.end());\n       return s == arr[lower_bound(arr.begin(),arr.end(),s)\n\t   - arr.begin()];\n        \n    }\n};\n```\n\nStep 1: Convert each power of 2 (upto 30) to string and sort all strings. \nStep 2: Push the resultant strings to global vector `arr`  in the sorted fashion.\n\nYour vector will look like something like this -\n```\n["0112344778","011237","0122579",\n"012356789","0124","0134449","0145678","01466788","0248",\n"0368888","0469","1","112234778","11266777","122446",\n"125","128","1289","13468","16","2","224588","23","23334455",\n"234455668","23678","256","35566","4","46","8"]\n```\n\nNow simply convert `n` to string `s`, sort it and apply binary search to find  `s` in `arr`\nEg - \nn = 251\ns = "251"\nafter sorting : s = "125"\nfind index of "125" in `arr` and retrive the index\nhere index will be 16,\nNow simply check whether string exists or not by `arr[index]==s`\nreturn it ;)\n\n*Upvote if it helped you*\n\n
[]