Title: #232 - Implement Queue using Stacks - LeetCode JavaScript Solutions
Open Graph Title: #232 - Implement Queue using Stacks - LeetCode JavaScript Solutions
X Title: #232 - Implement Queue using Stacks - LeetCode JavaScript Solutions
Description: Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue ...
Open Graph Description: Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue ...
X Description: Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue ...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/implement-queue-using-stacks
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/implement-queue-using-stacks","name":"#232 - Implement Queue using Stacks - LeetCode JavaScript Solutions","description":"Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue ...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"var MyQueue = function() {\n this.data = [];\n};\n\n/**\n * @param {number} x\n * @return {void}\n */\nMyQueue.prototype.push = function(x) {\n this.data.push(x);\n};\n\n/**\n * @return {number}\n */\nMyQueue.prototype.pop = function() {\n return this.data.shift();\n};\n\n/**\n * @return {number}\n */\nMyQueue.prototype.peek = function() {\n return this.data[0];\n};\n\n/**\n * @return {boolean}\n */\nMyQueue.prototype.empty = function() {\n return !this.data.length;\n};\n\n/**\n * Your MyQueue object will be instantiated and called as such:\n * var obj = new MyQueue()\n * obj.push(x)\n * var param_2 = obj.pop()\n * var param_3 = obj.peek()\n * var param_4 = obj.empty()\n */","keywords":"LeetCode 232, #232 - Implement Queue using Stacks, Easy, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/implement-queue-using-stacks |
| twitter:image | https://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/implement-queue-using-stacks/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0232-implement-queue-using-stacks.js |
| Stack | https://leetcodejavascript.com/tags/stack |
| Design | https://leetcodejavascript.com/tags/design |
| Queue | https://leetcodejavascript.com/tags/queue |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow