Compute Excel Range Products Excluding Each Cell Without Division

Last updated: November 29, 2026

Quick Overview

Given an array of numbers representing a row of Excel cells, return an array where each position holds the product of every other cell, without using division.

Microsoft
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Medium

0

0

0 solved


Given an array of numbers representing a row of Excel cells, return an array where each position holds the product of every other cell, without using division.

Shows up on Microsoft online assessments with an Excel flavor. Division is banned because zeros break it, so the interviewer looks for prefix and suffix products and an O(1) extra space version.

What the Interviewer Expects
  • Explain why division fails with zeros
  • Build prefix products left to right
  • Fold suffix products in a right-to-left pass
  • Use only the output array as extra space
  • Handle one zero and multiple zeros correctly
Key Topics to Cover
prefix products
arrays
space optimization
zeros
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle integer overflow for very long rows?
  • What if the row is updated frequently and queries interleave with updates?
  • Can you parallelize this over a huge range?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of n integers (n >= 2), possibly containing zeros and negatives. Output: list out where out[i] is the product of all elements except nums[i]. No division. Target O(n) time and O(1) e...

High-Level Design

out[i] equals (product of everything left of i) times (product of everything right of i). First pass: fill out[i] with the running product of elements before i. Second pass from the right: keep a ...


Submit Your Answer
Markdown supported