dfs that takes a NestedInteger and the current depth as arguments.total to store the running sum.NestedInteger is an integer, multiply its value by the current depth and add it to total.NestedInteger is a list, iterate over its elements and call dfs on each element with the depth incremented by 1.total after processing all elements.