Product Except Self
For each position, multiply every other number in the array, without division.
The problem
Implement Solution.productExceptSelf(nums). nums holds between 2 and 100,000 integers, which may be negative or zero. Return a list answer where answer[i] is the product of every number in nums except nums[i]. For [1, 2, 3, 4] the answer is [24, 12, 8, 6]. Do not use division. Run in O(n) time and use only O(1) extra space besides the answer list.
Starter code
class Solution:
def productExceptSelf(self, nums):
passPublic examples
nums = [1, 2, 3, 4]gives[24, 12, 8, 6]nums = [-3, 4]gives[4, -3]nums = [-2, 3, -4, 5]gives[-60, 40, -30, 24]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
