c++ most optimal || brute(tle) + optimal solution 
Intuition//The first missing power of 2 is the answer.
// we can actually produce all next pow(2,n)-1 from 1-pow(2,n-1)
//form 1,2,3,4 -> we can produce till 1-
# Intuition
//The first missing power of 2 is the answer.
// we can actually produce all next pow(2,n)-1 from 1-pow(2,n-1)
//form 1,2,3,4 -> we can produce till 1-7(3 bits set 111)
/*
Optimized Approach for minImpossibleOR
Instead of storing all possible OR results (which leads to exponential growth), we only need to find the smallest missing power of 2.

Why Does This Work?
Power of 2 numbers are unique in their binary form (only one bit set).
If nums contains 1, 2, 4, 8, ..., we can form all smaller OR combinations.
The first missing power of 2 is the answer.
# Complexity
- Time complexity:
o(n)

- Space complexity:
o(n)
![DALL·E 2025-01-10 01.06.09 - A cute puppy with the text 'Please Upvote' written over it in a playful and friendly font. The puppy is looking adorable, with big eyes and soft fur, .webp](https://assets.leetcode.com/users/images/13ba6d6d-2d62-48e0-8122-eccc92bcf694_1742854850.4766552.webp)

# Code
```cpp []
//The first missing power of 2 is the answer.
// we can actually produce all next pow(2,n)-1 from 1-pow(2,n-1)
//form 1,2,3,4 -> we can produce till 1-7(3 bits set 111)
/*
Optimized Approach for minImpossibleOR
Instead of storing all possible OR results (which leads to exponential growth), we only need to find the smallest missing power of 2.

Why Does This Work?
Power of 2 numbers are unique in their binary form (only one bit set).
If nums contains 1, 2, 4, 8, ..., we can form all smaller OR combinations.
The first missing power of 2 is the answer.

*/
class Solution{
    public:

int minImpossibleOR(vector<int>& nums) {
    unordered_set<int> st(nums.begin(), nums.end());
    int power = 1;
    while (st.count(power)) power <<= 1;  // Move to the next power of 2
    return power;
}
};


/* 1.approach->we are trying to OR num with all previously produced ORs by any subsequence(2pown)
//number of subsequece=2pown

24 / 73 testcases passed
class Solution {
    int smallestmissing(unordered_set<int>st){
   for(int i=1;i<=st.size();i++){
    if(st.find(i)==st.end()) return i;
   }
   //if all present return n+1;
   return st.size()+1;
    }
public:
    int minImpossibleOR(vector<int>& nums) {
    unordered_set<int>prev; //no need to take allset bcos now prev will store all elements
    for(int i=0;i<nums.size();i++){
        unordered_set<int>curr;
        curr.insert(nums[i]);
        //iterate over all prev OR
        for(auto it:prev) {
        curr.insert(it | nums[i]);
        }
        prev.insert(curr.begin(),curr.end());
    }
     //now find the min element which is not present in prev
     return smallestmissing(prev);
    }
};
*/



```
['Array', 'C++']