[Java] [1ms][100% Faster] Compare Frequency with all powers of 2
\n\n\n\nclass Solution {\n\n    public boolean reorderedPowerOf2(int n) {\n        final int[] frequency = new int[10];\n        int digitCount = 0;\n\n        
![image](https://assets.leetcode.com/users/images/0b1ac47e-d103-4d27-8578-cbe091e741ca_1661475383.0024922.png)\n\n\n```\nclass Solution {\n\n    public boolean reorderedPowerOf2(int n) {\n        final int[] frequency = new int[10];\n        int digitCount = 0;\n\n        while (n > 0) {\n            frequency[n % 10]++;\n            n /= 10;\n            digitCount++;\n        }\n\n        int currP = 1;\n\n        while (currP > 0) {\n            final int[] currFreq = new int[10];\n            int currDigitCount = 0;\n            int currN = currP;\n\n            while (currN > 0) {\n                currFreq[currN % 10]++;\n                currN /= 10;\n                currDigitCount++;\n            }\n\n            if (currDigitCount > digitCount) return false;\n            if (currDigitCount == digitCount && Arrays.equals(currFreq, frequency)) return true;\n\n            currP <<= 1;\n        }\n\n        return false;\n    }\n}\n```\n\n**Please Upvote :)**
['Bit Manipulation', 'Java']