Anaya Rojo
ES
← Blog

Coding problem: Get the product of all the other elements

June 2, 2021

daily coding problemarrays
Coding problem: Get the product of all the other elements

Given an array of integers, return a new array such that each element at index i of the new array is the result of multiplying all the numbers in the original array except the one at i.

For example:
Given the array [1, 2, 3, 4, 5], the expected result would be [120, 60, 40, 30, 24].
Given the array [3, 2, 1], the expected result would be [2, 3, 6].

Constraints:
You must not use division.

Solutions:
C#
Python
Javascript
Typescript
PHP