For each warehouse i, compute the product of all other warehouses' multipliers. You may not use division (multipliers can be 0).
Signature
productExceptSelf(nums: int[]) → int[]Example 1
nums = [1,2,3,4]
output = [24,12,8,6]
[2·3·4, 1·3·4, 1·2·4, 1·2·3]
Example 2
nums = [-1,1,0,-3,3]
output = [0,0,9,0,0]
Constraints
2 ≤ n ≤ 10^5-30 ≤ nums[i] ≤ 30every answer fits in a 32-bit int
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).