Challenge: Array of Products of All Elements

Given an array, return an array where each index stores the product of all numbers in the array except the number at the index itself.

Problem Statement #

Implement a function, findProduct(arr), which modifies an array so that each index has a product of all the numbers present in the array except the number stored at that index.

Note: The size of an array should be greater than or equal to 2.

Input #

An array of numbers (can even be floats, integers, and negative!)

Output #

An array such that each index has a product of all the numbers in the array except the number stored at that index.

Sample Input #

arr = [1,2,3,4]

Sample Output #

arr = [24,12,8,6]

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