Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
1 若需要在O(n)时间内完成,则可变换思路,用两次平行的for循环,用两个数组来进行乘积
2 第一个数组存储的是除了当前元素以外的所有previous元素的乘积
3 第二个数组存储的是除了当前元素之外的所有post的元素的乘积
4 然后将两个数组乘起来就行了
1 这道题的关键是,求除了它自己的所有的积,其实就是它左边所有elements积乘以它右边所有elements的积
2 所以有two pass,第一个pass求任何元素左边的积,第二遍求右边所有元素的积,在这个过程中,需要一个变量p来表示累积