Medium · Arrays

Product of Array Except Self

Given an integer array nums of length n ≥ 2, return an array out of the same length where out[i] is the product of every element of nums except nums[i], computed in O(n) time without using division.

Examples

Example 1

[1,2,3,4]

Output: [24,12,8,6]

Example 2

[2,3,5]

Output: [15,10,6]

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Arrays problems