Algorithm · LinkedIn · Medium
You are given a nested structure that holds integers. The structure is a list where each element is either an integer or another list of the same kind. Define the depth of an integer as the number of wrapping lists: outermost integers have depth 1, integers inside one level of nesting have depth 2, and so on. Let maxDepth be the largest depth among all integers in the whole structure. For an integer value v at depth d, its contribution to the answer is v * (maxDepth - d +…
Checking your access…