Binary Search!!Semi-Brute
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(10^4logn)\n\n- Space complexity:\nO(n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    void find_num(int low,int high,int num,vector<int> &ans,int ind){\n        for(int i=low;i<=high;i++){\n            int k=i|i+1;\n            if(k==num){\n                ans[ind]=i;\n                return;\n            }\n        }\n    }\n    void bin_search(int ind,int number,vector<int> &ans){\n        int l=0;\n        int high=number;\n        int m=(l+high)/2;\n        while(high-l>1e4){\n            m=l+(high-l)/2;\n            int k=m|(m+1);\n            if(k>number){\n                high=m-1;\n            }\n            else if(k==number){\n                ans[ind]=m;\n                high=m-1;\n            }\n            else{\n                l=m+1;\n            }\n        }\n        if(high-l<=1e4) find_num(l,high,number,ans,ind);\n    }\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n,-1);\n        for(int i=0;i<n;i++){\n            if(nums[i]%2==0){\n                ans[i]=-1;\n            }\n            else{\n                bin_search(i,nums[i],ans);\n            }\n        }\n        return ans;\n    }\n};\n```
['Math', 'Binary Search', 'C++']