dfs
that takes a nestedList
, the current depth
, and updates sumOfElements
, sumOfProducts
, and maxDepth
.NestedInteger
is an integer, add its value to sumOfElements
and its product with depth
to sumOfProducts
.NestedInteger
is a list, recursively call dfs
on each element in the list with depth + 1
.(maxDepth + 1) * sumOfElements - sumOfProducts
.