Python/Go O(log n) by digit-occurrence mapping [w/ Comment]
For example:\n\nGiven power of 2 = 2 ^ 6 = 64\n\n64 => {6: 1, 4: 1}\n6 shows up one time\n4 shows up one time\n\n---\n\nN=46 or N=64 return true because their d
For example:\n\nGiven power of 2 = 2 ^ 6 = 64\n\n64 => {6: 1, 4: 1}\n6 shows up one time\n4 shows up one time\n\n---\n\nN=46 or N=64 return **true** because their **digit - occurrence mapping** are the same with 64\n\n46 => {4: 1, 6: 1}\n4 shows up one time\n6 shows up one time\n\n64 => {6: 1, 4: 1}\n6 shows up one time\n4 shows up one time\n\n---\n\n**Implementation** by digit - occurrence mapping\n\nPython:\n\n```\nclass Solution:\n    def reorderedPowerOf2(self, N: int) -> bool:\n        \n        # digit <-> occurrence mapping of N\n        signature_of_N = Counter(str(N))\n        \n        \n        # check each possible power of 2\n        for i in range(32):\n            \n            # get power of 2 by bitwise operation\n            power_of_2 = 1 << i\n                \n            if Counter( str(power_of_2) ) == signature_of_N:\n                \n                # Accept if at least one power of 2\'s mapping is the same with N\'s mapping\n                return True\n        \n        # Reject otherwise\n        return False\n```\n\n---\n\n**Implementation** by digit - occurrence mapping based on recursion and decimal representation\n\nPython:\n\n```\nclass Solution:\n    def reorderedPowerOf2(self, N: int) -> bool:\n        \n        def make_signature(n: int):\n            \n\t\t\t## base case\n            if n == 0:\n                return 0\n            \n\t\t\t\n\t\t\t## general case\n\t\t\t\n            leading, remaining = divmod(n, 10)\n            return make_signature(leading) + ( 10 ** remaining )\n        \n        # ---------------------------------------------------------\n        \n        signature_of_N = make_signature(N)\n        \n\t\t# check each possible power of 2\n        for i in range(32):\n            \n\t\t\t# get power of 2 by bitwise operation, and check signature\n            if make_signature( 1 << i ) == signature_of_N:\n\t\t\t\n\t\t\t\t# Accept if at least one power of 2\'s signature is the same with N\'s signature\n                return True\n        \n\t\t# Reject otherwise\n        return False\n```\n\n---\n\n**Implementation** by digit - occurrence mapping based on recursion and decimal representation\n\nGo:\n\n```\nfunc reorderedPowerOf2(N int) bool {\n \n    var makeSignature func(n int) int\n    \n    makeSignature = func(n int) int {\n        \n        if n == 0{\n            // base case\n            return 0\n        }\n        \n        // general case\n        leading, remaining := n / 10, n % 10\n        return makeSignature( leading ) + int( math.Pow(10, float64(remaining) ) )\n        \n    }\n    \n    // -----------------------------------------------------\n    \n    signatureN := makeSignature( N )\n    \n    // check each possible power of 2\n    for i := 0 ; i < 32 ; i++ {\n        \n        if makeSignature( 1 << i ) == signatureN{\n            \n            // Accept if at least one power of 2\'s signature is the smae with N\'s\n            return true\n        }\n        \n    }\n    \n    // Reject otherwise\n    return false\n}\n```\n\n---\n\nReference:\n\n[1] [Python official docs about specialized dictionary Counter( ... )](https://docs.python.org/3/library/collections.html#collections.Counter)\n\n[2] [Python official docs about bitwise operation](https://wiki.python.org/moin/BitwiseOperators)
['Recursion', 'Python', 'Go', 'Python3']