Skip to content
Learn Netverks
Company prep Atlassian
Junior (1–3 years) Coding / DSA Medium

How do you solve product of array except self without division?

Reported in Atlassian interview loops. Array prefix-suffix pattern often asked in coding rounds.

Role
Software Engineer
Location
Pune

Context for Atlassian candidates:

Return an array where each index contains the product of all numbers except itself, without using division.

Try answering aloud first

Cover trade-offs, structure, and a concrete example before revealing the baseline response.

Spoiler-free prep mode

How to frame this at Atlassian: Connect your answer to measurable impact, clarity of thought, and trade-offs the team cares about. Below is a strong baseline response you can adapt with your own project examples.

Build prefix products from left to right and suffix products from right to left. The result at index i is prefix up to i-1 multiplied by suffix from i+1.

You can optimize space by storing prefix directly in the output array and using one running suffix variable in a backward pass. Time remains O(n) and extra space is O(1) excluding output.

Discuss why division-based logic fails with zeros, while prefix-suffix handles one or multiple zeros naturally.

Comments (0)

Share how this question came up in your loop, or add tips for others preparing.

Log in to comment on this question.