⚡⚡ Lightining Fast | 🧠🧠 High IQ | 🦸‍♂️🦸‍♂️ Marvel Approach
Logic?\n\nWe have used a special operation here  " << " , which is know as binary left operator.  The left operands value is moved left by the number of bits sp
**Logic?**\n\nWe have used a special operation here  " **<<** " , which is know as **binary left operator**.  The left operands value is moved left by the number of bits specified by the right operand.\n\nSo ,\n*1      = 00000000 00000000 00000000 00000001 = 1*\n*1 << 1 = 00000000 00000000 00000000 00000010 = 2*\n*1 << 8 = 00000000 00000000 00000001 00000000 = 256*\n\n***for e.g., 1<<6 will be 1(2^6)= 64***\n\n***So here we are just trying to store, 2 to the power i***\n\nHence, for each value of **i** in for loop it will give us the corresponding **power of 2** which we store in a string as digits!\n\n\n```\nclass Solution {\npublic:\n    bool reorderedPowerOf2(int n) {\n        \n       //Create a string to store the number as individual digits\n       string num = to_string(n);\n       \n       //Sort the string of digits\n       sort(num.begin(), num.end());\n        \n        //It is given that n lies in range [ 1 <= n <= 10^9 ]\n        //So, if n is a power of 2 it must exist between 2^0(=1) to 2^30(1073741824)\n        \n        //Hence, we loop from 0 to 29 and find all corresponding powers of 2\n        \n        for(int i = 0; i < 30; i++){\n            \n            //For each i, the respective power of 2 can be calculated as:\n            //**Logic is discussed above**\n            string powerOf2 = to_string(1 << i);\n            \n            //We again convert that number to string and sort its digits\n            sort(powerOf2.begin(), powerOf2.end());\n            \n            //If the resulting sorted string of digits is equal to num string then return True\n            if(num == powerOf2){\n                \n                return true;\n            }\n        }\n        \n        // Else, that number isn\'t a power of 2 and so return False\n        return false;\n    }\n};\n```\n\n**@Credits to @rahulvarma5297 and @divyamRai for the original answers!**\n\n![image](https://assets.leetcode.com/users/images/eb61f3be-ac79-49cd-9415-6fa8dc469155_1661541899.0942814.jpeg)\n\n\n\n
['C']