PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Adobe

Design a nested-list iterator

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to implement an efficient iterator over nested lists, testing skills in iterator state management, lazy traversal, explicit stack usage, and algorithmic complexity reasoning.

  • Medium
  • Adobe
  • Coding & Algorithms
  • Software Engineer

Design a nested-list iterator

Company: Adobe

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given a nested structure that can contain integers or further lists. Design an iterator over this structure that returns integers in left-to-right order without pre-flattening the entire input. Implement a class NestedIterator with: constructor(nestedList), boolean hasNext(), and int next(). The iterator must use O(d) extra space where d is the maximum nesting depth, and hasNext()/next() should be amortized O( 1). Avoid recursion by using an explicit stack of iterators or indexes. Additionally, implement a recursive pre-flattening approach, compare both methods in time and space complexity, and discuss edge cases such as empty lists, deeply nested empty lists, and integer bounds.

Quick Answer: This question evaluates the ability to implement an efficient iterator over nested lists, testing skills in iterator state management, lazy traversal, explicit stack usage, and algorithmic complexity reasoning.

Related Interview Questions

  • Traverse a path and print directory tree - Adobe (medium)
  • Build a React team builder with role constraints - Adobe (medium)
  • Implement K-means clustering from scratch - Adobe (medium)
  • Maximize pay by flipping k rest days - Adobe (Medium)
  • Determine task order with prerequisites - Adobe (Medium)
Adobe logo
Adobe
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0

You are given a nested structure that can contain integers or further lists. Design an iterator over this structure that returns integers in left-to-right order without pre-flattening the entire input. Implement a class NestedIterator with: constructor(nestedList), boolean hasNext(), and int next(). The iterator must use O(d) extra space where d is the maximum nesting depth, and hasNext()/next() should be amortized O( 1). Avoid recursion by using an explicit stack of iterators or indexes. Additionally, implement a recursive pre-flattening approach, compare both methods in time and space complexity, and discuss edge cases such as empty lists, deeply nested empty lists, and integer bounds.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Adobe•More Software Engineer•Adobe Software Engineer•Adobe Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.