// 339. Nested List Weight Sum
// https://leetcode.com/problems/nested-list-weight-sum/
func depthSum(nestedList []*NestedInteger) int {
return dfs339(nestedList, 1)
}
func dfs339(list []*NestedInteger, depth int) int {
sum := 0
for _, val := range list{
if val.IsInteger(){
sum += val.GetInteger() * depth
} else {
sum += dfs339(val.GetList(), depth + 1)
}
}
return sum
}