NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

(This question is a variation of the LeetCode question 251. Flatten 2D Vector. If you haven't completed that question yet, it is recommended to solve it first.)

Design an iterator to flatten a 2D vector so that all its integers can be accessed sequentially, row by row. In addition to standard iteration, the iterator must support removing the last returned element and provide access to the snapshot of the current vector state after any number of removals.

Implement the Vector2D class:

Test Cases
Input
Output
Expected