Challenge: Product of Array Except Self

Try to solve the Product of Array Except Self problem.

We'll cover the following

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 O(n)O(n) time without using the division operation.

Constraints:

  • 22 \leq nums.length 103\leq 10^3
  • 30-30 \leq nums[i] 30\leq 30
  • The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

Examples

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.