We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a3b377 commit a08eb49Copy full SHA for a08eb49
Design/251_Flatten_2D_Vector.java
@@ -0,0 +1,27 @@
1
+class Vector2D {
2
+ private int[][] v;
3
+ private int outer, inner;
4
+
5
+ public Vector2D(int[][] v) {
6
+ this.v = v;
7
+ outer = 0;
8
+ inner = 0;
9
+ }
10
11
+ private void advancedToNext() {
12
+ while (outer < v.length && inner == v[outer].length) {
13
14
+ ++outer;
15
16
17
18
+ public int next() {
19
+ advancedToNext();
20
+ return v[outer][inner++];
21
22
23
+ public boolean hasNext() {
24
25
+ return outer < v.length;
26
27
+}
0 commit comments