You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classSolution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> output(nums.size(), 1);
int left = 1;
for (int i = 0; i < nums.size(); i++) {
output[i] *= left;
left *= nums[i];
}
int right = 1;
for (int i = nums.size() - 1; i >= 0; i--) {
output[i] *= right;
right *= nums[i];
}
return output;
}
};
자신을 제외한 수를 곱한 결과라 포인터를 양쪽에서 곱해가며 구한다.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: