238. Product of Array Except Sel

2016-12-07  本文已影响0人  我是你的果果呀

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.)

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

上一篇 下一篇

猜你喜欢

热点阅读