class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
int size = nums.size();
std::vector<int> result(size, 1);
int left = 1;
int right = 1;
for (int i = 0, j = size - 1; i < size; ++i, --j) {
result[i] *= left;
result[j] *= right;
left *= nums[i];
right *= nums[j];
}
return result;
}
};