Beats 100% solutions
Intuition\n- Find the position of the first unset bit from LSB.\n- Now toggle the next bit to the right.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space com
# Intuition\n- Find the position of the first unset bit from LSB.\n- Now toggle the next bit to the right.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        int n = nums.size();\n        for (int i=0; i<n; i++) {\n            int pos = 0;\n            int temp = nums[i];\n            while (temp != 0) {\n                if((temp&1) == 1) {\n                    pos++;\n                    temp = temp >> 1;\n                } else {\n                    break;\n                }\n            }\n            if (pos != 0) {\n                nums[i] = nums[i] ^ (1 << (pos-1));\n            } else {\n                nums[i] = -1;\n            }\n        }\n        return nums;\n    }\n}; \n```
['Bitmask', 'C++']