AMAZON Phone interview 02/05

Given a nested list of int array - calculate the sum of all the integers, while multiplying each number by its depth.

For example:

Here's the depth sum of the nested list {1, {2, 3}}:

{1, {2, 3}} => 11 + 22 + 3*2 = 11

Here's the depth sum of the nested list {1, {2, {3}}}:

{1, {2, {3}}} => 11 + 22 + 3*3 = 14

Comments (1)