Simplest Explaned Solution
\nlet say we are given a number 46. So we need to check for 46 or 64 . If anyone of them is power of two then we will return true that there exist a permutation
\nlet say we are given a number 46. So we need to check for 46 or 64 . If anyone of them is power of two then we will return true that there exist a permutation who is Power of 2.\n\nDoes we need to **calculate every Permutaion :( ?**\n**NO :)** we just need to make a digit frequency map. and then compare that to power of two\'s .\n As digit can have only value 0 to 9 .  So instead of map can have a array of length 10.(0 to 9)\nTry to **understand through example :**\nLet say N=46 \n`InputDigit= [0,0,0,0,1,0,1,0,0,0]`\n**Start comparing it with Powers of 2.**\n2^0 =1 \n`digitArray=[0,1,0,0,0,0,0,0,0,0]`\n\n2^1=2\n`digitArray=[0,0,1,0,0,0,0,0,0,0]`\n\n2^2=4\n`digitArray=[0,0,0,0,1,0,0,0,0,0]`\n\n2^3=8\n`digitArray=[0,0,0,0,0,0,0,0,1,0]`\n\n2^4=16\n`digitArray=[0,1,0,0,0,0,1,0,0,0]`\n\n2^5=32\n`digitArray=[0,0,1,1,0,0,0,0,0,0]`\n\n2^6=64\n`digitArray=[0,0,0,0,1,0,1,0,0,0]`**SAME AS OF INPUT DIGITS ARRAY** return true\n\n\n```\nclass Solution {\n    public boolean reorderedPowerOf2(int N) {\n        int[] InputDigits=count(N);\n         \n        int powerOfTwo=1;\n        for(int i=0;i<31;i++){\n            int[] powerDigits=count(powerOfTwo);\n            if(isEqual(InputDigits,powerDigits)) return true;\n            powerOfTwo<<=1;  // leftShift basically multiplying by 2\n        }\n        return false;\n    }\n    \n    private boolean isEqual(int[] arr1,int[] arr2){\n        for(int i=0;i<arr1.length;i++){\n            if(arr1[i]!=arr2[i]) return false;\n        }\n        return true;\n    }\n    \n    private int[] count(int n){\n        int[] digitMap=new int[10];\n        while(n>0){\n            digitMap[n%10]++;\n            n/=10;\n        }\n        return digitMap;\n    }\n}\n```\nPlease **UPVOTE** if found it helpful :)
['Array', 'Bit Manipulation', 'Counting', 'Java']