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 {
55 vectors [][]int
66}
77
8- func Constructor (v1 [] int , v2 []int ) * ZigzagIterator {
8+ func Constructor (v1 , v2 []int ) * ZigzagIterator {
99 return & ZigzagIterator {
1010 cur : 0 ,
1111 size : 2 ,
@@ -14,7 +14,7 @@ func Constructor(v1 []int, v2 []int) *ZigzagIterator {
1414 }
1515}
1616
17- func (this * ZigzagIterator ) Next () int {
17+ func (this * ZigzagIterator ) next () int {
1818 vector := this .vectors [this .cur ]
1919 index := this .indexes [this .cur ]
2020 res := vector [index ]
@@ -23,7 +23,7 @@ func (this *ZigzagIterator) Next() int {
2323 return res
2424}
2525
26- func (this * ZigzagIterator ) HasNext () bool {
26+ func (this * ZigzagIterator ) hasNext () bool {
2727 start := this .cur
2828 for this .indexes [this .cur ] == len (this .vectors [this .cur ]) {
2929 this .cur = (this .cur + 1 ) % this .size
@@ -33,3 +33,11 @@ func (this *ZigzagIterator) HasNext() bool {
3333 }
3434 return true
3535}
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