As reported: Okta Senior Software Engineer (Node.js), India (2026), round 1 coding, the first of two problems. Also asked in another Okta Senior Software Engineer coding round, Bangalore (2026), after ~10 minutes of resume discussion: about 45 minutes went to coding, optimizing and discussing it, and the round ran out of time for a second question.
Given an integer array nums, return an array answer where answer[i] is the product of every element of nums except nums[i]. Run in O(n) time without using division. This is LeetCode 238 — Product of Array Except Self.
Example 1
nums = [1,2,3,4] -> [24,12,8,6]
Example 2
nums = [-1,1,0,-3,3] -> [0,0,9,0,0]
Constraints: 2 ≤ nums.length ≤ 10^5; -30 ≤ nums[i] ≤ 30; every prefix and suffix product fits in a 32-bit integer.
Follow-up: use O(1) extra space (the output array does not count).
Code runner format: one JSON value per line: nums (LeetCode's format). Implement productExceptSelf(nums); the harness prints the array.