FastPrepProduct Except Self With Zeros
Problems/Product Except Self With Zeros

Product Except Self With Zeros

Apple logoApple● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem is backed by an Apple interview-question post. The source code directly defines product except self and the three zero-count cases, but it did not include examples or constraints. The core task match is about 95%.

You are given an integer array nums. Return an array result where result[i] is the product of all elements in nums except nums[i].

Handle three zero cases:

  • If there are no zeroes, each position receives the product of all numbers divided by the current value.
  • If there is exactly one zero, only the zero position receives the product of all non-zero values.
  • If there is more than one zero, every output value is 0.

Function

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

Examples

Example 1

nums = [1,2,0,4]return = [0,0,8,0]

Only the index holding the zero gets a nonzero product; every other product includes the zero.

Constraints

  • The input contains integers.
  • In the no-zero case, integer division gives exact results.

More Apple Onsite Interview questions

  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Topological OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • FIFO Mutex Operation TraceONSITE INTERVIEW · Seen Oct 2026
  • Implement Hit CounterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Parse Nested HTML into a TreeONSITE INTERVIEW · Seen Oct 2026
  • Thread-Safe Concurrent Linked ListONSITE INTERVIEW · Seen Sep 2026
  • Palindrome Match PercentageONSITE INTERVIEW · Seen Sep 2026
  • Binary Tree Nodes at Distance KONSITE INTERVIEW · Seen Aug 2026
  • BST to Sorted Circular Doubly Linked ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Subarray Sum Equals KServiceNow · ONSITE INTERVIEWServiceNow interview questions
  • Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Range Booking TotalsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Product of Array Except SelfWalmart Labs · ONSITE INTERVIEW
  • Subarrays Whose Sum Is a Power of TwoKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Maximize Compatible Car RidersUber Freight · PHONE SCREEN · ONSITE INTERVIEWUber Freight interview questions
  • Count Subarrays with Sum KMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
  • Product Of Array Except SelfInfosys · ONSITE INTERVIEWInfosys interview questions
  • Centered K-by-K Submatrix SumsCitadel · ONSITE INTERVIEWCitadel interview questions
  • Farthest Affordable Shop per QueryAdobe · ONSITE INTERVIEWAdobe interview questions

Apple interview experiences

  • Apple SWE Phone Screen: Subarray Products: 1 Experience
  • Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
  • Apple AI Coding and Related Interviews: 17 Experiences
  • Apple India SWE New Grad Interviews: 5 Experiences
  • Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
  • Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)
All Apple interview questionsSee Apple hiring insights
Saved
class Solution {
    public int[] productExceptSelf(int[] nums) {
      // write your code here
    }
}
Checking account…