Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
530 B
1
Indexable
Never
int i = 0;
        vector<int> x;
        int j = nums.size()-1;
        int sum = nums.size()+1;
        while(i <= j){
            if(nums[i]+nums[j] != sum){
                if(nums[i] != i){
                    x.push_back(nums[i]);
                    x.push_back(i);                    
                }
                else{
                    x.push_back(nums[j]);
                    x.push_back(j);
                }
                i++;
                j--;
            }
        }
        return x;