Nested List Weight Sum
A medium-tier problem at 86% community acceptance, tagged with Depth-First Search, Breadth-First Search. Reported in interviews at Meta and 4 others.
Nested List Weight Sum is a medium-difficulty recursion trap that shows up in Meta, LinkedIn, and eBay assessments. The surface problem looks simple: sum integers in a nested list, but weight each by its depth. Most candidates write one solution and never realize there are two clean patterns to attack it. With an 85.5% acceptance rate, it's not the hardest medium you'll face, but it's a filter for candidates who can think recursively under pressure. If you blank on the depth-tracking trick during your live OA, StealthCoder runs invisibly and surfaces a working solution in seconds.
Companies that ask "Nested List Weight Sum"
Nested List Weight Sum is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe trap is overthinking the structure. You're given a nested list where elements are either integers or lists of integers. The naive read is 'iterate and recurse,' but the real trick is deciding whether to use depth-first search or breadth-first search and when to multiply. DFS is the natural fit: pass depth down, multiply each integer by its depth, recurse into sublists. Most candidates write working DFS on the first try. The real pitfall is breadth-first search, which forces you to track level explicitly with a queue and can trip up candidates who default to recursion. Either works, but mixing them up or losing track of when to apply the weight factor costs time. StealthCoder gives you both patterns instantly, so if you freeze on structure during the assessment, you're not scrambling for the next 20 minutes.
Pattern tags
You know the problem.
Make sure you actually pass it.
Nested List Weight Sum recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Nested List Weight Sum interview FAQ
Is this really just 'multiply each number by its depth'?+
Yes, but depth tracking is where candidates mess up. DFS passes depth as a parameter down the recursion stack. BFS forces you to manually track level in a queue. The math is trivial once structure is clear. Most solutions are 10-15 lines.
Do Meta and LinkedIn really ask this?+
Yes. It's in the problem sets for both Meta and LinkedIn, along with eBay, Snap, and Nextdoor. It's not a heavy hitter, but frequent enough that seeing it in your OA wouldn't be a surprise.
What's the catch with breadth-first search here?+
BFS requires you to pair each element with its depth using a queue of tuples or a separate level counter. It's not harder, just less intuitive than DFS. If you're strong with recursion, DFS is faster to code and less error-prone during a timed assessment.
How does this relate to other recursion problems I should know?+
It combines depth-first search and breadth-first search fundamentals with basic tree traversal. Master this, and you've got the mental model for nested-structure problems across trees, graphs, and flattened lists.
Can I use Python's built-in recursion limit as an excuse?+
Not really. The nesting depth in real assessments is shallow enough that Python's default 1000-call limit never fires. If your solution hits recursion limits, you've written something wrong, not hit a language limitation.
Want the actual problem statement? View "Nested List Weight Sum" on LeetCode →