LinkedIn interview question

Leetcode's nested list weight sum-2