Given an array of integers, replace each element of the array with the product of every other element in the array. Return the modified array.
Let array arr
equal to [ 1, 2, 3, 4, 5 ]
. If we multiply the elements accordingly, we'll get the array [ 120, 60, 40, 30, 24 ]
. The solution should return this array.