```
int depth = 1, sum = 0;
public int depthSum(List<NestedInteger> nestedList) {
for(NestedInteger n : nestedList)
{
if(n.isInteger())
sum += n.getInteger() * depth;
else
{
depth++;
sum = depthSum(n.getList());
}
}
depth--;
return sum;
}
```