Search
⌘K

Leetcode 251. Flatten 2D Vector

Implement an iterator over a 2D vector that yields integers in row-major order via next() and hasNext(). The core challenge is maintaining indices and skipping empty inner lists efficiently so iteration remains correct and amortized O(1) per operation.

Asked at:

Meta

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid February, 2025

Meta

Mid-level

Late November, 2024

Google

Google

Mid-level

Implement a 2D vector iterator (similar to LeetCode's Flatten 2D Vector problem)

Comments

Your account is free and you can post anonymously if you choose.