238. Product of Array Except Self

Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].
Solve it without division and in O(n).
For example, given[1,2,3,4], return[24,12,8,6].

Follow up:
Could you solve it with constant space complexity? (Note: The output arraydoes notcount as extra space for the purpose of space complexity analysis.)

不能用除法, 那么采用这个数左边数的乘积 乘以右边数的乘积,即得到所要结果。

238. Product of Array Except Self_第1张图片

你可能感兴趣的:(238. Product of Array Except Self)