Solution with explanation
Approach\nThe key insight here is that x | (x + 1) will always be equal to num if and only if the least significant bit of num is 1. This is because x | (x + 1)
# Approach\nThe key insight here is that x | (x + 1) will always be equal to num if and only if the least significant bit of num is 1. This is because x | (x + 1) will always set the least significant bit of num to 1.\n\nBy iterating over each num and finding the smallest x that satisfies the condition, we can construct the result array.\n\n# Complexity\n- Time complexity:\n$$O(n*m)$$, where n is the length of the input list nums and m is the maximum value in nums. This is because for each number in nums, the function iterates up to that number to find a match.\n\n- Space complexity:\n$$O(n)$$, where n is the length of the input list nums. This is because the function creates a new list ans of the same length as nums to store the results.\n\n# Code\n```python3 []\nclass Solution:\n    def minBitwiseArray(self, nums: List[int]) -> List[int]:\n        ans = []\n        for num in nums:\n            found = False\n            for x in range(num):\n                if (x | (x + 1)) == num:\n                    ans.append(x)\n                    found = True\n                    break\n            if not found:\n                ans.append(-1)\n        return ans\n```\n``` javascript []\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar minBitwiseArray = function(nums) {\n    const ans = [];\n    for (const num of nums) {\n        let found = false;\n        for (let x = 0; x < num; x++) {\n            if ((x | (x + 1)) === num) {\n                ans.push(x);\n                found = true;\n                break;\n            }\n        }\n        if (!found) {\n            ans.push(-1);\n        }\n    }\n    return ans;\n};\n```\n``` php []\nclass Solution {\n\n    /**\n     * @param Integer[] $nums\n     * @return Integer[]\n     */\n    function minBitwiseArray($nums) {\n        $ans = [];\n        foreach ($nums as $num) {\n            $found = false;\n            for ($x = 0; $x < $num; $x++) {\n                if (($x | ($x + 1)) === $num) {\n                    $ans[] = $x;\n                    $found = true;\n                    break;\n                }\n            }\n            if (!$found) {\n                $ans[] = -1;\n            }\n        }\n        return $ans;\n        }\n}\n```
['Array', 'Bit Manipulation', 'PHP', 'Python3', 'JavaScript']