Product Except Self

L4 Easy Arrays & Hashing
Concept
Prefix and suffix products let every position see the effect of all other elements without ever dividing.
For each position i, compute the product of every element of nums except nums[i], and return those values in order. Solve it in linear time and without using division.
Examples
▸ nums = [1, 2, 3, 4]
→ [24, 12, 8, 6]
▸ nums = [-1, 1, 0, -3, 3]
→ [0, 0, 9, 0, 0]
▸ nums = [2, 3]
→ [3, 2]
Progressive Hints
Hint 1 · Nudge
Split the product into everything on the left and everything on the right.
Hint 2 · Plan
First pass builds an answer array where slot i holds the product of everything to its left. Second pass walks backward multiplying each slot by the product of everything to its right, tracking the running right product as you go.
Hint 3 · Approach
answer[i] = running product of nums up to i - 1, filled left to right. right = 1; for i from the last index to 0: answer[i] = answer[i] * right, then right = right * nums[i]. Return answer.
Output
// Run your code to see the output here.