Iterator LeetCode Problems: All 9, With Python Solutions

Every problem in this library that LeetCode tags Iterator 9 in total, 5 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 9 problems
  • 1 Easy
  • 8 Medium
  • 0 Hard

Iterator problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (1)

#ProblemDifficultyTopics
604Design Compressed String IteratorPremiumEasyDesign, Array, String +1

Medium (8)

#ProblemDifficultyTopics
173Binary Search Tree IteratorMediumStack, Tree, Design +3
284Peeking IteratorMediumDesign, Array, Iterator
341Flatten Nested List IteratorMediumStack, Tree, Depth-First Search +3
900RLE IteratorMediumDesign, Array, Counting +1
1286Iterator for CombinationMediumDesign, String, Backtracking +1
251Flatten 2D VectorPremiumMediumDesign, Array, Two Pointers +1
281Zigzag IteratorPremiumMediumDesign, Queue, Array +1
1586Binary Search Tree Iterator IIPremiumMediumStack, Tree, Design +3

When the Iterator problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.