```
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> outp(nums);
int n = nums.size();
int x = 1;
for (int i = 0; i< n-1 ; i++) {
x *=nums[i];
outp[i] = x;
}
outp[n-1] = x;
for (int i = n-2; i > 0 ; i--) {
outp[i] = outp[i-1] * nums[i+1];
nums[i] = nums[i+1] * nums[i];
}
outp[0] = nums[1];
return outp;
}
```