Beats 100% | Easy C++ Solution
Code\ncpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n),v;\n      
# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n),v;\n        for(int i=0;i<n;i++){\n            if(nums[i]==2){\n                ans[i]=-1;\n            }else{\n                int some=nums[i];\n                while(some>0){\n                    if(some%2){\n                        v.push_back(1);\n                    }else{\n                        v.push_back(0);\n                    }\n                    some/=2;\n                }\n                int val=nums[i],sub=1;\n                for(int i=0;i<v.size();i++){\n                    if(v[i]==0){\n                        break;\n                    }\n                    sub=sub*2;\n                }\n                sub/=2;\n                ans[i]=val-sub;\n                v.clear();\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']