Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Product of Array Except Self

Medium Arrays

Given an integer array nums, print an array answer where answer[i] is the product of all elements of nums except nums[i]. You must not use division and the solution must run in O(n).

Constraints

2 <= n <= 10^5 -30 <= nums[i] <= 30 The product of any prefix or suffix fits in a 32-bit integer

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.