{"id":839,"date":"2025-08-06T11:14:55","date_gmt":"2025-08-06T05:44:55","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=839"},"modified":"2025-08-06T11:14:57","modified_gmt":"2025-08-06T05:44:57","slug":"implement-queue-using-stacks","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/","title":{"rendered":"Implement Queue using Stacks | Leetcode 232 | Using 2 stacks"},"content":{"rendered":"\n<p>Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (<code>push<\/code>,&nbsp;<code>peek<\/code>,&nbsp;<code>pop<\/code>, and&nbsp;<code>empty<\/code>).<\/p>\n\n\n\n<p>Here&#8217;s the [<strong><a href=\"https:\/\/leetcode.com\/problems\/implement-queue-using-stacks\/description\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Problem Link<\/span><\/mark><\/a><\/strong>] to begin with.<\/p>\n\n\n\n<p>Implement the&nbsp;<code>MyQueue<\/code>&nbsp;class:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>void push(int x)<\/code>\u00a0Pushes element x to the back of the queue.<\/li>\n\n\n\n<li><code>int pop()<\/code>\u00a0Removes the element from the front of the queue and returns it.<\/li>\n\n\n\n<li><code>int peek()<\/code>\u00a0Returns the element at the front of the queue.<\/li>\n\n\n\n<li><code>boolean empty()<\/code>\u00a0Returns\u00a0<code>true<\/code>\u00a0if the queue is empty,\u00a0<code>false<\/code>\u00a0otherwise.<\/li>\n<\/ul>\n\n\n\n<p><strong>Notes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You must use\u00a0<strong>only<\/strong>\u00a0standard operations of a stack, which means only\u00a0<code>push to top<\/code>,\u00a0<code>peek\/pop from top<\/code>,\u00a0<code>size<\/code>, and\u00a0<code>is empty<\/code>\u00a0operations are valid.<\/li>\n\n\n\n<li>Depending on your language, the stack may not be supported natively. You may simulate a stack using a list or deque (double-ended queue) as long as you use only a stack&#8217;s standard operations.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input<\/strong><br>[\"MyQueue\", \"push\", \"push\", \"peek\", \"pop\", \"empty\"]<br>[[], [1], [2], [], [], []]<br><br><strong>Output<\/strong><br>[null, null, null, 1, 1, false]<br><br><strong>Explanation<\/strong><br>MyQueue myQueue = new MyQueue();<br>myQueue.push(1); \/\/ queue is: [1]<br>myQueue.push(2); \/\/ queue is: [1, 2] (leftmost is front of the queue)<br>myQueue.peek(); \/\/ return 1<br>myQueue.pop(); \/\/ return 1, queue is [2]<br>myQueue.empty(); \/\/ return false<\/pre>\n\n\n\n<p><strong>Explanation<\/strong> MyQueue myQueue = new MyQueue(); myQueue.push(1); \/\/ queue is: [1] myQueue.push(2); \/\/ queue is: [1, 2] (leftmost is front of the queue) myQueue.peek(); \/\/ return 1 myQueue.pop(); \/\/ return 1, queue is [2] myQueue.empty(); \/\/ return false<\/p>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>1 &lt;= x &lt;= 9<\/code><\/li>\n\n\n\n<li>At most\u00a0<code>100<\/code>\u00a0calls will be made to\u00a0<code>push<\/code>,\u00a0<code>pop<\/code>,\u00a0<code>peek<\/code>, and\u00a0<code>empty<\/code>.<\/li>\n\n\n\n<li>All the calls to\u00a0<code>pop<\/code>\u00a0and\u00a0<code>peek<\/code>\u00a0are valid.<\/li>\n<\/ul>\n\n\n\n<p><strong>Follow-up:<\/strong>&nbsp;Can you implement the queue such that each operation is&nbsp;<strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Amortized_analysis\" target=\"_blank\" rel=\"noreferrer noopener\">amortized<\/a><\/strong>&nbsp;<code>O(1)<\/code>&nbsp;time complexity? In other words, performing&nbsp;<code>n<\/code>&nbsp;operations will take overall&nbsp;<code>O(n)<\/code>&nbsp;time even if one of those operations may take longer.<\/p>\n\n\n<div class=\"wp-block-ub-table-of-contents-block ub_table-of-contents\" id=\"ub_table-of-contents-e06c290f-920b-45b6-8d91-7d0cb6c56776\" data-linktodivider=\"false\" data-showtext=\"show\" data-hidetext=\"hide\" data-scrolltype=\"auto\" data-enablesmoothscroll=\"false\" data-initiallyhideonmobile=\"false\" data-initiallyshow=\"true\"><div class=\"ub_table-of-contents-header-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-header\" style=\"text-align: left; \">\n\t\t\t\t<div class=\"ub_table-of-contents-title\">Contents:<\/div>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t<\/div><div class=\"ub_table-of-contents-extra-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-container ub_table-of-contents-1-column \">\n\t\t\t\t<ul style=\"\"><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#0-intuition-amp-approach\" style=\"\">Intuition &amp; Approach<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#1-why-use-two-stacks\" style=\"\">Why Use Two Stacks?<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#2-how-does-this-work\" style=\"\">How Does This Work?<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#3-code-implementation\" style=\"\">Code Implementation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#4-code-explanation\" style=\"\">Code Explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#5-time-and-space-complexity\" style=\"\">Time and Space Complexity<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/implement-queue-using-stacks\/#6-conclusion\" style=\"\">Conclusion<\/a><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0-intuition-amp-approach\">Intuition &amp; Approach<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-why-use-two-stacks\">Why Use Two Stacks?<\/h3>\n\n\n\n<p>A&nbsp;<strong>queue<\/strong>&nbsp;is FIFO (first-in, first-out); a&nbsp;<strong>stack<\/strong>&nbsp;is LIFO (last-in, first-out). By cleverly combining two stacks, you can reverse the LIFO order to achieve the desired FIFO behavior.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-how-does-this-work\">How Does This Work?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>in_stack<\/strong>\u00a0receives new elements (acts like the back of the queue).<\/li>\n\n\n\n<li><strong>out_stack<\/strong>\u00a0gives elements in &#8220;queue order&#8221; (the front of the queue).<\/li>\n<\/ul>\n\n\n\n<p>When you need to pop or peek:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If out_stack is empty, dump all elements from in_stack into out_stack (reversing their order).<\/li>\n\n\n\n<li>If out_stack is not empty, use it directly.<\/li>\n<\/ul>\n\n\n\n<p>This &#8220;delayed reversal&#8221; ensures each element is reversed only once, keeping operations efficient on average (amortized O(1) time).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-code-implementation\">Code Implementation<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"class MyQueue:\n    def __init__(self):\n        # Two stacks: in_stack (for push), out_stack (for pop\/peek)\n        self.in_stack = []\n        self.out_stack = []\n\n    def push(self, x: int) -&gt; None:\n        # Add to in_stack (end of queue)\n        self.in_stack.append(x)\n\n    def pop(self) -&gt; int:\n        # Pop from out_stack (front of queue)\n        self.peek()  # Ensure out_stack has the current items\n        return self.out_stack.pop()\n\n    def peek(self) -&gt; int:\n        # Get the front element\n        if not self.out_stack:\n            # Transfer all from in_stack to out_stack if needed, reversing order\n            while self.in_stack:\n                self.out_stack.append(self.in_stack.pop())\n        return self.out_stack[-1]\n\n    def empty(self) -&gt; bool:\n        # Queue is empty only if both stacks are empty\n        return not self.in_stack and not self.out_stack\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">MyQueue<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">__init__<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Two stacks: in_stack (for push), out_stack (for pop\/peek)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.in_stack = []<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack = []<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">push<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">x<\/span><span style=\"color: #D4D4D4\">: <\/span><span style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">) -&gt; <\/span><span style=\"color: #569CD6\">None<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Add to in_stack (end of queue)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.in_stack.append(x)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">pop<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">) -&gt; <\/span><span style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Pop from out_stack (front of queue)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.peek()  <\/span><span style=\"color: #6A9955\"># Ensure out_stack has the current items<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack.pop()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">peek<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">) -&gt; <\/span><span style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Get the front element<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #6A9955\"># Transfer all from in_stack to out_stack if needed, reversing order<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">while<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.in_stack:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack.append(<\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.in_stack.pop())<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack[-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">empty<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">) -&gt; <\/span><span style=\"color: #4EC9B0\">bool<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Queue is empty only if both stacks are empty<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.in_stack <\/span><span style=\"color: #569CD6\">and<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.out_stack<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-code-explanation\">Code Explanation<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>push(x)<\/code><\/strong>: Always adds new elements to in_stack, which is simple and O(1).<\/li>\n\n\n\n<li><strong><code>pop()<\/code><\/strong>: If out_stack is empty, transfer all elements from in_stack (which reverses their order). This lets you pop the oldest element, just like a queue.<\/li>\n\n\n\n<li><strong><code>peek()<\/code><\/strong>: Ensures the next element to pop is on top of out_stack; if not, does the same transferring as in\u00a0<code>pop()<\/code>, then returns the top of out_stack.<\/li>\n\n\n\n<li><strong><code>empty()<\/code><\/strong>: The queue is empty if BOTH stacks have no elements left.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-time-and-space-complexity\">Time and Space Complexity<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>push<\/strong>: O(1)<\/li>\n\n\n\n<li><strong>pop<\/strong>: Amortized O(1) (costly transfers only when out_stack is empty, and each element is moved at most once)<\/li>\n\n\n\n<li><strong>peek<\/strong>: Amortized O(1)<\/li>\n\n\n\n<li><strong>empty<\/strong>: O(1)<\/li>\n\n\n\n<li><strong>Space<\/strong>: O(n), where n = number of queue elements<\/li>\n<\/ul>\n\n\n\n<p><strong>In simple words:<\/strong><br>Normal operations are constant time; only occasional transfers take extra time, but spread across all operations they average out to \u201cfast enough\u201d (O(1) per operation).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Implementing a queue using two stacks is an interview classic for a reason. It elegantly demonstrates both the difference between LIFO and FIFO structures and how you can achieve one using the other. Practice this pattern, then try similar challenges like&nbsp;<em>stack using queues<\/em>&nbsp;to deeply strengthen your data structure skills!<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/codeanddebug.in\/course\/zero-to-hero-python-dsa\" target=\"_blank\" rel=\"noreferrer noopener\">Join our Advance DSA COURSE<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>For any changes to the article, kindly email at <a href=\"mailto:code@codeanddebug.in\" target=\"_blank\" rel=\"noreferrer noopener\">code@codeanddebug.in<\/a> or contact us at <a href=\"tel:+91-9712928220\" target=\"_blank\" rel=\"noreferrer noopener\">+91-9712928220<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push,&nbsp;peek,&nbsp;pop, and&nbsp;empty). Here&#8217;s the [Problem Link] to begin with. Implement the&nbsp;MyQueue&nbsp;class: Notes: Example 1: Input[&#8220;MyQueue&#8221;, &#8220;push&#8221;, &#8220;push&#8221;, &#8220;peek&#8221;, &#8220;pop&#8221;, &#8220;empty&#8221;][[], [1], [2], [], [], []]Output[null, null, null, 1, 1, false]ExplanationMyQueue myQueue<\/p>\n","protected":false},"author":1,"featured_media":841,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[8,37],"class_list":{"0":"post-839","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-structures-and-algorithm","8":"category-beginner","9":"tag-easy","10":"tag-stack-and-queues"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/08\/implement-queue-using-stacks-featured-image.png","author_info":{"display_name":"codeanddebug","author_link":"https:\/\/codeanddebug.in\/blog\/author\/codeanddebug\/"},"_links":{"self":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/comments?post=839"}],"version-history":[{"count":1,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/839\/revisions"}],"predecessor-version":[{"id":842,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/839\/revisions\/842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/841"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}