标签:cpp array leetcode cte sel https code cep size
https://leetcode.com/problems/product-of-array-except-self/description/
解题思路:
http://blog.csdn.net/wzy_1988/article/details/46916179
class Solution { public: vector<int> productExceptSelf(vector<int>& nums) { vector<int> result(nums.size()); result[0] = 1; int p = 1; for (int i = 1; i < nums.size(); i++){ p *= nums[i-1]; result[i] = p; } p = 1; for (int i = nums.size()-2; i >= 0; i--){ p *= nums[i+1]; result[i] *= p; } return result; } };
LeetCode: Product of Array Except Self
标签:cpp array leetcode cte sel https code cep size
原文地址:http://www.cnblogs.com/yxzfscg/p/7467141.html