✅FINDING RIGHTMOST UNSET BIT🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal of this function is to modify each element in the given array nums \nbased on 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal of this function is to modify each element in the given array `nums` \nbased on certain bitwise operations. The modification is aimed at finding a \nsmaller number by flipping the rightmost unset bit. The function handles a \nspecial case where the number is 2, returning -1. For other numbers, it searches \nfor the lowest unset bit (starting from the least significant bit) and flips \nthe bit just before it. \n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create a vector `ans` to store the results.\n2. Loop through each element `i` in the input vector `nums`:\n   - If `i` is 2, push -1 to the result vector `ans`.\n   - Otherwise, loop from bit position 1 to 30:\n     - Check if the bit at position `j` is unset in `i` using `(i & (1 << j))`.\n     - If the bit is set, continue to the next position.\n     - If the bit is unset, flip the bit at position `j-1` using `i ^ (1 << (j-1))`\n       and push the modified value to `ans`. Break out of the loop.\n3. Return the vector `ans` containing the modified values.\n# Complexity\n- Time complexity:O(N * 31)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> minBitwiseArray(vector<int>& nums) {\n        vector<int> ans;\n        for(int i:nums){\n            if(i==2){\n                ans.push_back(-1);\n            }else{\n                for(int j=1;j<31;j++){\n                    if(i&(1<<j)){\n                        continue;\n                    }else{\n                        ans.push_back(i^(1<<(j-1)));\n                        break;\n                    }\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Array', 'Bit Manipulation', 'C++']