Medium · Arrays

Self exclude product

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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Arrays problems