Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Build the result in two passes without using division. First pass computes prefix products: result[i] holds the product of all elements before index i. Second pass multiplies in suffix products from right to left. Each result[i] becomes prefix[i] * suffix[i].
The product of all elements except self at index i is the product of everything to its left times everything to its right. Two passes accumulate these partial products without needing division.
Updated Feb 2026