Easy DP solution :)
\n\n# Code\ncpp []\nclass Solution {\n    unordered_map<int, int> dp;\n\n    int solve(int num){\n        if(dp[num]) return dp[num];\n        if(floor(log2(num
\n\n# Code\n```cpp []\nclass Solution {\n    unordered_map<int, int> dp;\n\n    int solve(int num){\n        if(dp[num]) return dp[num];\n        if(floor(log2(num + 1)) == ceil(log2(num + 1))) return ((num + 1) / 2) - 1;\n\n        int val = pow(2, (int)log2(num));\n\n        return dp[num] = val + solve(num - val);\n    }\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        vector<int> ans;\n        dp[1] = 0;\n\n        for(auto it : nums){\n            if(it == 2) ans.push_back(-1);\n            else{\n                ans.push_back(solve(it));\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']