René's URL Explorer Experiment


Title: #281 - Zigzag Iterator - LeetCode JavaScript Solutions

Open Graph Title: #281 - Zigzag Iterator - LeetCode JavaScript Solutions

X Title: #281 - Zigzag Iterator - LeetCode JavaScript Solutions

Description: Given two vectors of integers v1 and v2, implement an iterator to return their elements alternately. Implement the ZigzagIterator class: Zi...

Open Graph Description: Given two vectors of integers v1 and v2, implement an iterator to return their elements alternately. Implement the ZigzagIterator class: Zi...

X Description: Given two vectors of integers v1 and v2, implement an iterator to return their elements alternately. Implement the ZigzagIterator class: Zi...

Keywords:

Opengraph URL: https://leetcodejavascript.com/solutions/zigzag-iterator

direct link

Domain: leetcodejavascript.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/zigzag-iterator","name":"#281 - Zigzag Iterator - LeetCode JavaScript Solutions","description":"Given two vectors of integers v1 and v2, implement an iterator to return their elements alternately. Implement the ZigzagIterator class:  Zi...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @constructor\n * @param {Integer[]} v1\n * @param {Integer[]} v2\n */\nvar ZigzagIterator = function ZigzagIterator(v1, v2) {\n  this.queue = [];\n  if (v1.length) this.queue.push([v1, 0]);\n  if (v2.length) this.queue.push([v2, 0]);\n};\n\n/**\n * @this ZigzagIterator\n * @returns {boolean}\n */\nZigzagIterator.prototype.hasNext = function hasNext() {\n  return this.queue.length > 0;\n};\n\n/**\n * @this ZigzagIterator\n * @returns {integer}\n */\nZigzagIterator.prototype.next = function next() {\n  const [vector, index] = this.queue.shift();\n  const value = vector[index];\n\n  if (index + 1 < vector.length) {\n    this.queue.push([vector, index + 1]);\n  }\n\n  return value;\n};","keywords":"LeetCode 281, #281 - Zigzag Iterator, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}

authorLeetCodeJavascript.com
og:typearticle
og:imagehttps://leetcodejavascript.com/og-image.jpg
og:site_nameLeetCode JavaScript Solutions
twitter:cardsummary_large_image
twitter:urlhttps://leetcodejavascript.com/solutions/zigzag-iterator
twitter:imagehttps://leetcodejavascript.com/og-image.jpg
twitter:creator@joshcrozier
theme-color#1f2937

Links:

LeetCodeJavascript.com https://leetcodejavascript.com/
Star on GitHub https://github.com/JoshCrozier/leetcode-javascript
Back to all solutions https://leetcodejavascript.com
View on LeetCode https://leetcode.com/problems/zigzag-iterator/
View on GitHub https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0281-zigzag-iterator.js
Array https://leetcodejavascript.com/tags/array
Design https://leetcodejavascript.com/tags/design
Queue https://leetcodejavascript.com/tags/queue
Iterator https://leetcodejavascript.com/tags/iterator
Josh Crozierhttps://joshcrozier.com

Viewport: width=device-width, initial-scale=1.0

Robots: index, follow


URLs of crawlers that visited me.