educative.io

Incorrect example output

Challenge: Array of Products of All Elements

Has a incorrect example image.


for input [4,2,1,5,0] > output will be [10, 20, 40, 8, 40] but currently it is [0,0,0,0,40]

Hi @Samrat_Saha !!
Problem: Implement a function called findProduct(arr) that takes an array of integers as input and modifies it so that each index stores the product of all the numbers in the array except the number at that index. The function should return the modified array.

For example, given the input [4, 2, 1, 5, 0], the function should modify the array as follows:

  • Index 0: The product should be 2 * 1 * 5 * 0 = 0
  • Index 1: The product should be 4 * 1 * 5 * 0 = 0
  • Index 2: The product should be 4 * 2 * 5 * 0 = 0
  • Index 3: The product should be 4 * 2 * 1 * 0 = 0
  • Index 4: The product should be 4 * 2 * 1 * 5 = 40

Therefore, the expected output for the input [4, 2, 1, 5, 0] is [0, 0, 0, 0, 40].
I hope it helps. Happy Learning