Given an integer array nums, construct and return an array output such that output[i] equals the product of every value in nums other than nums[i].
You may assume that every product fits within a 32-bit integer.
Follow-up: Can you achieve O(n)O(n)O(n) time complexity without using division?
Example 1:
Input: nums = [1,2,4,6]
Output: [48,24,12,8]
Each result is the product of all array values except the value at the corresponding index.
nums = [1, 2, 4, 6][48,24, 12, 8]
We start with the input array nums = [1, 2, 4, 6].
Example 2:
Input: nums = [-1,0,1,2,3]
Output: [0,-6,0,0,0]
The zero causes the products for every position except its own to be zero, while excluding the zero produces -6.
2 <= nums.length <= 1000-20 <= nums[i] <= 20nums = [1, 2, 4, 6][48,24, 12, 8]
We start with the input array nums = [1, 2, 4, 6].