Solution: Product of Array Except Self
Let’s solve the Product of Array Except Self problem.
Statement
You’re given an integer array, nums
. Return a resultant array product
so that product[i]
is equal to the product of all the elements of nums
except nums[i]
.
Write an algorithm that runs in time without using the division operation.
Constraints:
-
nums.length
-
nums[i]
- The product of any prefix or suffix of
nums
is guaranteed to fit in a 32-bit integer.
Solution 1: Brute force
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.