Question bank › Recursion
Dsa Recursion Warm-up

Nested List Sum

You are given a nested list of integers, where each element can be either an integer or another list (which may also contain further nested lists). Write a function that computes the sum of all integers in the nested list, regardless of how deeply nested they are. Input Format: A single line containing a nested list representation (using Python list syntax). Output Format: A single integer representing the sum of all integers in the nested list. Example: Input: [1, [2, [3, 4], 5], 6] Output: 21

Key concepts

recursionsumminglists

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.