```
class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> result;
int current = 1;
for (int i = 0;i < nums.size();++ i) {
result.push_back(current);
current *= nums[i];
}
int n = nums.size();
current = 1;
for (int i = n-1;i >= 0;-- i) {
result[i] = current * result[i];
current *= nums[i];
}
return result;
}
};
```