Tap here to switch tabs
Problem
Submissions

Problem: Nested List Weight Sum

med
30 min
Try to solve the Nested List Weight Sum problem.

Statement

Given a nested list nestedList of NestedInteger elements, compute the weighted sum of all integers contained in it.

Each integer contributes its value multiplied by its depth, where the depth of an integer is the number of lists from the outermost list down to the integer. The outermost level has depth 11.

Return the total weighted sum.

Constraints:

  • 1≤1 \leq nestedList.length ≤50\leq 50

  • Each integer value in nestedList is in the range [−100,100][-100, 100]

  • The maximum depth of any integer is ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Nested List Weight Sum

med
30 min
Try to solve the Nested List Weight Sum problem.

Statement

Given a nested list nestedList of NestedInteger elements, compute the weighted sum of all integers contained in it.

Each integer contributes its value multiplied by its depth, where the depth of an integer is the number of lists from the outermost list down to the integer. The outermost level has depth 11.

Return the total weighted sum.

Constraints:

  • 1≤1 \leq nestedList.length ≤50\leq 50

  • Each integer value in nestedList is in the range [−100,100][-100, 100]

  • The maximum depth of any integer is ≤50\leq 50