Product sum of a special Array : Explanation

Опубликовано: 19 Июнь 2026
на канале: HeadEasyLabs
328
1

lets move forward to our next example for recursion.
Product sum of array.

actually product sum of a special array.

Special array is the array consisting numbers and other arrays!

for example,

1, 2, [ 3, 2 ], 6, [ [ 2, 4 ], 1], 7

this array is having numbers 1, 2, 6, 7 as its elements but other than that it also has other arrays as its elements as well.
like at position 2, it is having another array with elements 3,2. at position 4 it's another special array with again an array and 1 as its elements.

now lets discuss, what problem statement wants us to solve:
you need to calculate sum of all of its elements and multiply with the depth of the special array.. For this complete special array the depth is 1. and for the array [3,2] the depth will be 2 because its an array inside an array. and similarly, for the array [2,4] the depth is 3 .