File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
solution/0200-0299/0281.Zigzag Iterator Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ type ZigzagIterator struct {
5
5
vectors [][]int
6
6
}
7
7
8
- func Constructor (v1 [] int , v2 []int ) * ZigzagIterator {
8
+ func Constructor (v1 , v2 []int ) * ZigzagIterator {
9
9
return & ZigzagIterator {
10
10
cur : 0 ,
11
11
size : 2 ,
@@ -14,7 +14,7 @@ func Constructor(v1 []int, v2 []int) *ZigzagIterator {
14
14
}
15
15
}
16
16
17
- func (this * ZigzagIterator ) Next () int {
17
+ func (this * ZigzagIterator ) next () int {
18
18
vector := this .vectors [this .cur ]
19
19
index := this .indexes [this .cur ]
20
20
res := vector [index ]
@@ -23,7 +23,7 @@ func (this *ZigzagIterator) Next() int {
23
23
return res
24
24
}
25
25
26
- func (this * ZigzagIterator ) HasNext () bool {
26
+ func (this * ZigzagIterator ) hasNext () bool {
27
27
start := this .cur
28
28
for this .indexes [this .cur ] == len (this .vectors [this .cur ]) {
29
29
this .cur = (this .cur + 1 ) % this .size
@@ -33,3 +33,11 @@ func (this *ZigzagIterator) HasNext() bool {
33
33
}
34
34
return true
35
35
}
36
+
37
+ /**
38
+ * Your ZigzagIterator object will be instantiated and called as such:
39
+ * obj := Constructor(param_1, param_2);
40
+ * for obj.hasNext() {
41
+ * ans = append(ans, obj.next())
42
+ * }
43
+ */
You can’t perform that action at this time.
0 commit comments