{"id":904,"date":"2025-08-19T12:27:43","date_gmt":"2025-08-19T06:57:43","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=904"},"modified":"2025-08-19T12:27:44","modified_gmt":"2025-08-19T06:57:44","slug":"asteroid-collision","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/asteroid-collision\/","title":{"rendered":"Asteroid Collision | Leetcode 735 | Optimal Stack Solution"},"content":{"rendered":"\n<p>We are given an array&nbsp;<code>asteroids<\/code>&nbsp;of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space.<\/p>\n\n\n\n<p>For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.<\/p>\n\n\n\n<p>Find out the state of the asteroids after all collisions. If two asteroids meet, the smaller one will explode. If both are the same size, both will explode. Two asteroids moving in the same direction will never meet.<\/p>\n\n\n\n<p>Here&#8217;s the [<strong><a href=\"https:\/\/leetcode.com\/problems\/asteroid-collision\/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><strong>Example 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> asteroids = [5,10,-5]<br><strong>Output:<\/strong> [5,10]<br><strong>Explanation:<\/strong> The 10 and -5 collide resulting in 10. The 5 and 10 never collide.<\/pre>\n\n\n\n<p><strong>Example 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> asteroids = [8,-8]<br><strong>Output:<\/strong> []<br><strong>Explanation:<\/strong> The 8 and -8 collide exploding each other.<\/pre>\n\n\n\n<p><strong>Example 3:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Input:<\/strong> asteroids = [10,2,-5]<br><strong>Output:<\/strong> [10]<br><strong>Explanation:<\/strong> The 2 and -5 collide resulting in -5. The 10 and -5 collide resulting in 10.<\/pre>\n\n\n\n<p><strong>Constraints:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>2 &lt;= asteroids.length &lt;= 10<sup>4<\/sup><\/code><\/li>\n\n\n\n<li><code>-1000 &lt;= asteroids[i] &lt;= 1000<\/code><\/li>\n\n\n\n<li><code>asteroids[i] != 0<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span style=\"text-decoration: underline;\">Optimal Approach:\u00a0<strong>Monotonic Stack<\/strong>\u00a0Simulation<\/span><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Intuition<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use a\u00a0<strong>stack<\/strong>\u00a0to maintain asteroids that are\u00a0<strong>stable<\/strong>\u00a0so far.<\/li>\n\n\n\n<li><strong>Push<\/strong>\u00a0all\u00a0<strong>right-moving<\/strong>\u00a0asteroids directly; they can only collide with a\u00a0<strong>future left-moving<\/strong>\u00a0one.<\/li>\n\n\n\n<li>When encountering a\u00a0<strong>left-moving<\/strong>\u00a0asteroid, resolve collisions with the stack\u2019s\u00a0<strong>right-moving<\/strong>\u00a0tops:\n<ul class=\"wp-block-list\">\n<li><strong>Pop<\/strong>\u00a0all\u00a0<strong>smaller<\/strong>\u00a0right movers.<\/li>\n\n\n\n<li>If the top has the\u00a0<strong>same size<\/strong>,\u00a0<strong>pop it<\/strong>\u00a0and\u00a0<strong>discard<\/strong>\u00a0the current one (<strong>both explode<\/strong>).<\/li>\n\n\n\n<li>If the stack is\u00a0<strong>empty<\/strong>\u00a0or top is a\u00a0<strong>left mover<\/strong>, the current left mover\u00a0<strong>survives<\/strong>;\u00a0<strong>push<\/strong>\u00a0it.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>This simulates the process in a&nbsp;<strong>single pass<\/strong>&nbsp;with amortized&nbsp;<strong>O(1)<\/strong>&nbsp;per asteroid, leading to&nbsp;<strong>O(n)<\/strong>&nbsp;time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/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 Solution:\n    def asteroidCollision(self, asteroids):\n\n        # Size of the array\n        n = len(asteroids)\n\n        # List implementation of stack\n        st = []\n\n        # Traverse all the asteroids\n        for i in range(n):\n\n            # Push the asteroid in stack if a\n            # right moving asteroid is seen\n            if asteroids[i] &gt; 0:\n                st.append(asteroids[i])\n\n            # Else if the asteroid is moving\n            # left, perform the collisions\n            else:\n\n                # Until the right moving asteroids are\n                # smaller in size, keep on destroying them\n                while st and st[-1] &gt; 0 and st[-1] &lt; abs(asteroids[i]):\n\n                    # Destroy the asteroid\n                    st.pop()\n\n                # If there is right moving asteroid\n                # which is of same size\n                if st and st[-1] == abs(asteroids[i]):\n\n                    # Destroy both the asteroids\n                    st.pop()\n\n                # Otherwise, if there is no left\n                # moving asteroid, the right moving\n                # asteroid will not be destroyed\n                elif not st or st[-1] &lt; 0:\n\n                    # Storing the array in final state\n                    st.append(asteroids[i])\n\n        # Return the final state of asteroids\n        return st\" 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\">Solution<\/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\">asteroidCollision<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">asteroids<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Size of the array<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        n = <\/span><span style=\"color: #DCDCAA\">len<\/span><span style=\"color: #D4D4D4\">(asteroids)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># List implementation of stack<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        st = []<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Traverse all the asteroids<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">for<\/span><span style=\"color: #D4D4D4\"> i <\/span><span style=\"color: #C586C0\">in<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">range<\/span><span style=\"color: #D4D4D4\">(n):<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #6A9955\"># Push the asteroid in stack if a<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #6A9955\"># right moving asteroid is seen<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> asteroids[i] &gt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                st.append(asteroids[i])<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #6A9955\"># Else if the asteroid is moving<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #6A9955\"># left, perform the collisions<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">else<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># Until the right moving asteroids are<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># smaller in size, keep on destroying them<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #C586C0\">while<\/span><span style=\"color: #D4D4D4\"> st <\/span><span style=\"color: #569CD6\">and<\/span><span style=\"color: #D4D4D4\"> st[-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">] &gt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">and<\/span><span style=\"color: #D4D4D4\"> st[-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">] &lt; <\/span><span style=\"color: #DCDCAA\">abs<\/span><span style=\"color: #D4D4D4\">(asteroids[i]):<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    <\/span><span style=\"color: #6A9955\"># Destroy the asteroid<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    st.pop()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># If there is right moving asteroid<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># which is of same size<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> st <\/span><span style=\"color: #569CD6\">and<\/span><span style=\"color: #D4D4D4\"> st[-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">] == <\/span><span style=\"color: #DCDCAA\">abs<\/span><span style=\"color: #D4D4D4\">(asteroids[i]):<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    <\/span><span style=\"color: #6A9955\"># Destroy both the asteroids<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    st.pop()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># Otherwise, if there is no left<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># moving asteroid, the right moving<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #6A9955\"># asteroid will not be destroyed<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #C586C0\">elif<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> st <\/span><span style=\"color: #569CD6\">or<\/span><span style=\"color: #D4D4D4\"> st[-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">] &lt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    <\/span><span style=\"color: #6A9955\"># Storing the array in final state<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                    st.append(asteroids[i])<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Return the final state of asteroids<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> st<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works (<strong>Conceptual Walkthrough<\/strong>)<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Right movers<\/strong>\u00a0(<strong>positive<\/strong>) are appended since they\u00a0<strong>won\u2019t collide immediately<\/strong>.<\/li>\n\n\n\n<li>For a\u00a0<strong>left mover<\/strong>\u00a0(<strong>negative<\/strong>), it may collide with prior\u00a0<strong>right movers<\/strong>:\n<ul class=\"wp-block-list\">\n<li>While the top of the stack is a\u00a0<strong>smaller right mover<\/strong>:\u00a0<strong>pop it<\/strong>\u00a0(it explodes).<\/li>\n\n\n\n<li>If the top is the\u00a0<strong>same size<\/strong>:\u00a0<strong>pop it<\/strong>\u00a0and\u00a0<strong>do not push<\/strong>\u00a0the current (both\u00a0<strong>explode<\/strong>).<\/li>\n\n\n\n<li>If the stack is\u00a0<strong>empty<\/strong>\u00a0or top is a\u00a0<strong>left mover<\/strong>:\u00a0<strong>push<\/strong>\u00a0the current left mover (<strong>no collision<\/strong>\u00a0now).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>This process ensures collisions are resolved in the\u00a0<strong>correct order<\/strong>\u00a0as they would occur\u00a0<strong>on the line<\/strong>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"time-and-space-complexity\">Time and Space Complexity<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Time:<\/strong>\u00a0<strong>O(n)<\/strong>\u00a0&#8211; each asteroid is\u00a0<strong>pushed<\/strong>\u00a0and\u00a0<strong>popped<\/strong>\u00a0at most once.<\/li>\n\n\n\n<li><strong>Space:<\/strong>\u00a0<strong>O(n)<\/strong>\u00a0in the worst case for the\u00a0<strong>stack<\/strong>\u00a0(when\u00a0<strong>no collisions<\/strong>\u00a0happen).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Edge Cases<\/strong>&nbsp;and&nbsp;<strong>Tips<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>All positives:<\/strong>\u00a0return\u00a0<strong>same list<\/strong>\u00a0(no collisions).<\/li>\n\n\n\n<li><strong>All negatives:<\/strong>\u00a0return\u00a0<strong>same list<\/strong>\u00a0(no collisions).<\/li>\n\n\n\n<li><strong>Equal sizes:<\/strong>\u00a0both\u00a0<strong>vanish<\/strong>.<\/li>\n\n\n\n<li>Large sequences of\u00a0<strong>small positives<\/strong>\u00a0followed by a\u00a0<strong>big negative<\/strong>: the loop\u00a0<strong>pops many items<\/strong> &#8211; still\u00a0<strong>amortized O(n)<\/strong>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">When to Use This&nbsp;<strong>Pattern<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Any linear\u00a0<strong>collision<\/strong>\u00a0or\u00a0<strong>cancellation<\/strong>\u00a0simulation with\u00a0<strong>direction<\/strong>\u00a0and\u00a0<strong>magnitude<\/strong>\u00a0can often be modeled with a\u00a0<strong>stack<\/strong>\u00a0(e.g., removing adjacent conflicts, evaluating left-right interactions).<\/li>\n\n\n\n<li>The key is to define\u00a0<strong>when elements interact<\/strong>\u00a0(here:\u00a0<strong>positive followed by negative<\/strong>) and what\u00a0<strong>rules<\/strong>\u00a0resolve them.<\/li>\n<\/ul>\n\n\n\n<p>This solution is\u00a0<strong>concise<\/strong>,\u00a0<strong>robust<\/strong>, and\u00a0<strong>optimal<\/strong>\u00a0for the\u00a0<strong>Asteroid Collision<\/strong>\u00a0problem, ready for\u00a0<strong>interviews<\/strong>\u00a0and\u00a0<strong>production<\/strong>.<\/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>We are given an array&nbsp;asteroids&nbsp;of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out<\/p>\n","protected":false},"author":1,"featured_media":905,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[19,37],"class_list":{"0":"post-904","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-structures-and-algorithm","8":"category-intermediate","9":"tag-medium","10":"tag-stack-and-queues"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/08\/asteroid-collision-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\/904","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=904"}],"version-history":[{"count":1,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/904\/revisions"}],"predecessor-version":[{"id":906,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/904\/revisions\/906"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/905"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}