Simple Java Solution Based on String Sorting
The idea here is similar to that of group Anagrams problem (Leetcode #49). \n\nFirst, we convert the input number (N) into a string and sort the string. Next, w
The idea here is similar to that of group Anagrams problem (Leetcode #49). \n\nFirst, we convert the input number (N) into a string and sort the string. Next, we get the digits that form the power of 2 (by using 1 << i and vary i), convert them into a string, and then sort them. As we convert the powers of 2 (and there are only 31 that are <= 10^9), for each power of 2, we compare if the string is equal to that of string based on N. If the two strings are equal, then we return true.\n\n```\nclass Solution {\n    public boolean reorderedPowerOf2(int N) {\n        char[] a1 = String.valueOf(N).toCharArray();\n        Arrays.sort(a1);\n        String s1 = new String(a1);\n        \n        for (int i = 0; i < 31; i++) {\n            char[] a2 = String.valueOf((int)(1 << i)).toCharArray();\n            Arrays.sort(a2);\n            String s2 = new String(a2);\n            if (s1.equals(s2)) return true;\n        }\n        \n        return false;\n    }\n}\n```
[]