Product of Array Except Self

Medium · Arrays & Strings · about 20 minutes

Asked at Amazon, Meta, Apple, Uber.

Build an output array of the same length as nums in which position i holds nums[0] × … × nums[n-1] with nums[i] left out of the product. Division is off the table; aim for O(n) time.