FastPrepProduct of Array Except Self
Problems/Product of Array Except Self

Product of Array Except Self

New Relic logoNew Relic● MediumONSITE INTERVIEW
QuestionFunctionExamples

Problem statement

Source note: This problem is backed by a real New Relic technical interview report. The report linked Product of Array Except Self and said the interviewer expected the optimized solution, but it did not reproduce the function interface, examples, or constraints. The core task match is about 95%.

Given an integer array nums, return an array answer where answer[i] is the product of every element of nums except nums[i].

Do not use division.

Interview Follow-up

The interviewer asked for the most optimized solution from the start and then had the candidate run two test cases.

Function

productExceptSelf(nums: int[]) → int[]

Examples

Example 1

nums = [1,2,3,4]return = [24,12,8,6]

Each position contains the product of all values except the one at that position.

Example 2

nums = [-1,1,0,-3,3]return = [0,0,9,0,0]

Only the index containing 0 receives the product of all nonzero values.

More New Relic problems

  • Basic String Compression with Length GuardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Longest Increasing Path in a MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
See New Relic hiring insights
Saved
class Solution {
    public int[] productExceptSelf(int[] nums) {
      // write your code here
    }
}
Checking account…