Implement an iterator to flatten a 2d vector.
Example
No.1
Input:[[1,2],[3],[4,5,6]]
Output:[1,2,3,4,5,6]
No.2
Input:[[7,9],[5]]
Output:[7,9,5]
Code
1 | private Iterator<List<Integer>> row; |
写BUG的程序猿
Implement an iterator to flatten a 2d vector.
Input:[[1,2],[3],[4,5,6]]
Output:[1,2,3,4,5,6]
Input:[[7,9],[5]]
Output:[7,9,5]
1 | private Iterator<List<Integer>> row; |