As reported: Zscaler Senior Staff / Staff SDE loop (2026), round 1 (DSA coding): after an introduction and a discussion of the security best practices you follow, two LeetCode problems — this one and Longest Mountain in Array.
This is LeetCode 238 — Product of Array Except Self. Our write-up: /product-of-array-except-self.
Given an integer array nums, return an array answer where answer[i] is the product of all elements of nums except nums[i]. The product of any prefix or suffix fits in a 32-bit integer. Solve it in O(n) time without using division.
Example 1
nums = [1, 2, 3, 4]
Output: [24, 12, 8, 6]
Example 2
nums = [-1, 1, 0, -3, 3]
Output: [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.
Code runner format: one JSON value per line: nums. Implement productExceptSelf(nums).
Clarifications
- Follow-up worth having ready: O(1) extra space, not counting the output array.