← AlgoMindset 75

Product of Array Except Self

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

Given an integer array nums, return an array answer such that answer[i] is the product of all the elements of nums except nums[i]. You must not use division, and the algorithm must run in O(n).

[1,2,3,4] → [24,12,8,6]

🎬 Video explanation · NeetCode

Your solution runs against 2 unit tests, including edge and large-value cases.

Loading...

Test console · 2 unit tests

Submit your code to run it against all 2 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Want the full interview treatment — the conversation, the why, and step-by-step visuals? Read the deep dive →