← All problems
Product of Array Except Self
Given nums, return an array where answer[i] is the product of all elements except nums[i]. No division; O(n) time.
Complexity
Time O(n), Space O(1) excluding output
Common pitfalls
- Using division (fails on zeros)
- Extra arrays when O(1) space is required
Your solution
Log in to save your code and track progress.