C++ | Bit Manipulation | Beats 100%
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\n    int harsh(int n){\n        int m=log2(n)+1;\n\n        if(n==2) return -1;\n        int flag=0;\n        int x=0;\n\n        for(int i=0; i<m; i++){\n            if((n&(1<<i))==0){\n                flag=1;\n                x=i-1;\n                break;\n            }\n        }\n\n        int ans=0;\n\n        if(!flag){\n            ans=n>>1;\n        }\n        else ans=(n^(1<<x));\n\n        return ans;\n    }\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n);\n\n        for(int i=0; i<n; i++){\n            ans[i]=harsh(nums[i]);\n        }\n\n        return ans;\n    }\n};\n```
['Bit Manipulation', 'C++']