{"id":47,"date":"2025-05-08T20:02:00","date_gmt":"2025-05-08T14:32:00","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=47"},"modified":"2025-05-08T20:03:10","modified_gmt":"2025-05-08T14:33:10","slug":"remove-duplicates-from-sorted-array-leetcode-26","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/","title":{"rendered":"Remove duplicates from Sorted array &#8211; Leetcode 26"},"content":{"rendered":"\n<p>Hi everyone, in this article we&#8217;ll guide you through the Python program to Remove Duplicates from Soroted Array <strong>(in-place)<\/strong> [<strong><a href=\"https:\/\/leetcode.com\/problems\/remove-duplicates-from-sorted-array\/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>]. We will see both the <strong>brute-force<\/strong> and <strong>optimal<\/strong> solution and dry run. So let&#8217;s begin.<\/p>\n\n\n<div style=\"max-width: -moz-fit-content; \" class=\"wp-block-ub-table-of-contents-block ub_table-of-contents\" id=\"ub_table-of-contents-e65f3063-1a63-49b5-8f74-9c18db2747d1\" data-linktodivider=\"false\" data-showtext=\"show\" data-hidetext=\"hide\" data-scrolltype=\"auto\" data-enablesmoothscroll=\"true\" 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\"><\/div>\n\t\t\t\t<div class=\"ub_table-of-contents-header-toggle\">\n\t\t\t<div class=\"ub_table-of-contents-toggle\" style=\"\">\n\t\t\t\u00a0[<a class=\"ub_table-of-contents-toggle-link\" href=\"#\" style=\"\">hide<\/a>]\n\t\t\t<\/div>\n\t\t<\/div>\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\/remove-duplicates-from-sorted-array-leetcode-26\/#0-understand-the-problem\" style=\"\">Understand the problem<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#1-simple-question-explanation\" style=\"\">Simple Question Explanation:<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#2-example\" style=\"\">Example:<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#3-input\" style=\"\">Input:<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#4-output\" style=\"\">Output:<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#5-key-constraints\" style=\"\">Key Constraints:<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#6-1-brute-force-solution-with-dictionary\" style=\"\">1. Brute Force Solution (With Dictionary)<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#7-intuition-and-approach\" style=\"\">Intuition and Approach<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#8-code\" style=\"\">Code<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#9-code-explanation\" style=\"\">Code Explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#10-dry-run-with-images\" style=\"\">Dry Run (with images)<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#11-edge-cases-to-consider\" style=\"\">Edge cases to consider<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#12-time-and-space-complexity\" style=\"\">Time and Space Complexity<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#13-2-optimal-solution-with-two-pointers\" style=\"\">2. Optimal Solution (With Two Pointers)<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#14-intuition-and-approach\" style=\"\">Intuition and Approach<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#15-code\" style=\"\">Code<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#16-code-explanation\" style=\"\">Code Explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#17-dry-run-with-images\" style=\"\">Dry Run (with images)<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#18-edge-cases-to-consider\" style=\"\">Edge cases to consider<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/remove-duplicates-from-sorted-array-leetcode-26\/#19-time-and-space-complexity\" style=\"\">Time and Space Complexity<\/a><\/li><\/ul><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"0-understand-the-problem\">Understand the problem<\/h2>\n\n\n\n<p>This problem <strong>&#8220;Remove Duplicates from Sorted Array&#8221;<\/strong> is about modifying a sorted array <strong>in place<\/strong> to remove duplicate values while keeping the original order. The goal is to return the number of unique elements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-simple-question-explanation\">Simple Question Explanation:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>You are given a sorted array (non-decreasing order).<\/li>\n\n\n\n<li>You need to remove duplicate values so that each unique number appears <strong>only once<\/strong>.<\/li>\n\n\n\n<li>The remaining unique elements should be placed at the beginning of the array.<\/li>\n\n\n\n<li>You cannot use extra space (i.e., no new array), so the changes must be done <strong>in place<\/strong>.<\/li>\n\n\n\n<li>The function should return the count of unique numbers.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-example\">Example:<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-input\">Input:<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" 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;line-height:1.25rem;--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:#282A36\"><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=\"nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4]\" style=\"color:#F8F8F2;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 dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">nums <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> [<\/span><span style=\"color: #BD93F9\">0<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">0<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">2<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">2<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">3<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">3<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">4<\/span><span style=\"color: #F8F8F2\">]<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4-output\">Output:<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" 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;line-height:1.25rem;--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:#282A36\"><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=\"nums = [0, 1, 2, 3, 4, _, _, _, _, _]\" style=\"color:#F8F8F2;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 dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">nums <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> [<\/span><span style=\"color: #BD93F9\">0<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">2<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">3<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #BD93F9\">4<\/span><span style=\"color: #F8F8F2\">, _, _, _, _, _]<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Explanation:<\/strong> The first <code>5<\/code> elements are the unique values, and the remaining elements are ignored.<\/p>\n\n\n\n<p><strong>Return value:<\/strong> <code>5<\/code> (since there are 5 unique numbers).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-key-constraints\">Key Constraints:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The array is already <strong>sorted<\/strong>.<\/li>\n\n\n\n<li>You <strong>must<\/strong> modify the array in place (without using extra space).<\/li>\n\n\n\n<li>The function should return the count of unique elements.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Also read about the Python Program to <strong><a href=\"https:\/\/codeanddebugacademy.com\/rotate-an-array-by-k-places\/\" 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;\">Rotate an Array by K Places<\/span><\/mark><\/a><\/strong><\/em>.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-1-brute-force-solution-with-dictionary\">1. Brute Force Solution (With Dictionary)<\/h2>\n\n\n\n<p>This approach will use dictionary to store unique elements and then use it to put it back into the original array. This might not be the most optimal solution, but we can still get to our answer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-intuition-and-approach\">Intuition and Approach<\/h3>\n\n\n\n<p>The solution uses a dictionary <strong>(my_dict)<\/strong> to track the unique elements of the array. Since dictionary keys in Python are unique, inserting each element of the array as a key in the dictionary automatically removes any duplicates. The approach is straightforward:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Populate the dictionary with the elements of the array.<\/li>\n\n\n\n<li>Iterate through the dictionary keys, which are guaranteed to be unique, and copy them back into the original array nums.<\/li>\n\n\n\n<li>The new length of the array without duplicates is then the count of these unique keys.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8-code\">Code<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" 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;line-height:1.25rem;--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:#282A36\"><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 removeDuplicates(self, nums: List[int]) -&gt; int:\n        my_dict = dict()\n        for i in nums:\n            my_dict[i] = 0\n\n        j = 0\n        for n in my_dict:\n            nums[j] = n\n            j += 1\n        return j\" style=\"color:#F8F8F2;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 dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">Solution<\/span><span style=\"color: #F8F8F2\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">def<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">removeDuplicates<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #BD93F9; font-style: italic\">self<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">nums<\/span><span style=\"color: #FF79C6\">:<\/span><span style=\"color: #F8F8F2\"> List[<\/span><span style=\"color: #8BE9FD; font-style: italic\">int<\/span><span style=\"color: #F8F8F2\">]) <\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">int<\/span><span style=\"color: #F8F8F2\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        my_dict <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">dict<\/span><span style=\"color: #F8F8F2\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">for<\/span><span style=\"color: #F8F8F2\"> i <\/span><span style=\"color: #FF79C6\">in<\/span><span style=\"color: #F8F8F2\"> nums:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            my_dict[i] <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">0<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        j <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">for<\/span><span style=\"color: #F8F8F2\"> n <\/span><span style=\"color: #FF79C6\">in<\/span><span style=\"color: #F8F8F2\"> my_dict:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            nums[j] <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> n<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            j <\/span><span style=\"color: #FF79C6\">+=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">return<\/span><span style=\"color: #F8F8F2\"> j<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9-code-explanation\">Code Explanation<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>A dictionary <strong>my_dict<\/strong> is initialized to store each unique element of <strong>nums<\/strong>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>First Loop &#8211; Removing Duplicates:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Iterates over each element <strong>i<\/strong> in <strong>nums<\/strong>.<\/li>\n\n\n\n<li>Adds <strong>i<\/strong> to <strong>my_dict <\/strong>as a key. If <strong>i<\/strong> is already a key in the dictionary, it does nothing (ignoring duplicates).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Second Loop &#8211; Reassigning to <\/strong><strong>nums<\/strong><strong>:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>j<\/strong> is initialized to <strong>0 <\/strong>to act as the index for the next unique element in <strong>nums<\/strong>.<\/li>\n\n\n\n<li>Iterates through the keys in <strong>my_dict <\/strong>(which are the unique elements).<\/li>\n\n\n\n<li>Each key <strong>n<\/strong> is placed back into <strong>nums[j]<\/strong>, and <strong>j<\/strong> is incremented.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Return Statement:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Returns <strong>j,<\/strong> the number of unique elements placed back into nums.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10-dry-run-with-images\">Dry Run (with images)<\/h3>\n\n\n\n<p>Let&#8217;s walk through a step-by-step dry run with a sample input:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-1024x576.png\" alt=\"1st image of Dry run of brute force solution to remove duplicates from the array\" class=\"wp-image-48\" srcset=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-1024x576.png 1024w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-300x169.png 300w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-768x432.png 768w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-1536x864.png 1536w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-150x84.png 150w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-450x253.png 450w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1-1200x675.png 1200w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step1.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-1024x576.png\" alt=\"2nd image of Dry run of brute force solution to remove duplicates from the array\" class=\"wp-image-49\" srcset=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-1024x576.png 1024w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-300x169.png 300w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-768x432.png 768w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-1536x864.png 1536w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-150x84.png 150w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-450x253.png 450w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2-1200x675.png 1200w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sroted-array-brute-force-step2.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"11-edge-cases-to-consider\">Edge cases to consider<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Empty Array:<\/strong> If nums is empty (<strong>nums = []<\/strong>), our code correctly returns <strong>0<\/strong> and makes no changes.<\/li>\n\n\n\n<li><strong>Array with No Duplicates:<\/strong> If the array already contains no duplicates (e.g., nums = [1, 2, 3]), our function will return the original length of the array.<\/li>\n\n\n\n<li><strong>All Elements Identical:<\/strong> For an array where all elements are identical (e.g., nums = [1, 1, 1]), our function will return <strong>1<\/strong>, with the <strong>first element <\/strong>being the unique one.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"12-time-and-space-complexity\">Time and Space Complexity<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Time Complexity:<\/strong> The time complexity is <strong><em>O(n + n)<\/em><\/strong>, where <strong>n<\/strong> is the length of the array. This is because of <strong>one pass <\/strong>to fill the dictionary and <strong>another <\/strong>to update the array.<\/li>\n\n\n\n<li><strong>Space Complexity:<\/strong> The space complexity is <strong><em>O(k)<\/em><\/strong>, where <strong>k<\/strong> is the number of unique elements in nums. In the worst case (all elements are unique), this is <strong><em>O(n)<\/em><\/strong>.<\/li>\n<\/ul>\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 python with dsa course<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"13-2-optimal-solution-with-two-pointers\">2. Optimal Solution (With Two Pointers)<\/h2>\n\n\n\n<p>To solve this problem we will be using two pointers as <strong>i<\/strong> and <strong>j<\/strong>. Check out the solution below to understand what are we trying to do and understand through the images via dry run.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"14-intuition-and-approach\">Intuition and Approach<\/h3>\n\n\n\n<p>Given that the array is <strong>sorted<\/strong>, our solution utilizes the <strong>two-pointer <\/strong>technique to effectively filter out duplicates in-place. The main idea is to maintain two pointers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>i points<\/strong> to the last position of the unique elements encountered so far.<\/li>\n\n\n\n<li><strong>j<\/strong> will loop through the array giving us non duplicates.<\/li>\n<\/ul>\n\n\n\n<p>If <strong>nums[j]<\/strong> is not equal to <strong>nums[i]<\/strong>, it means <strong>nums[j]<\/strong> is a unique element that hasn&#8217;t been recorded yet. Therefore, <strong>nums[j]<\/strong> is swapped with <strong>nums[i+1]<\/strong>, effectively growing the list of unique elements by one. The process ensures that all unique elements are shifted to the front of the array in their original order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"15-code\">Code<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" 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;line-height:1.25rem;--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:#282A36\"><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 removeDuplicates(self, nums: List[int]) -&gt; int:\n        if len(nums) == 1:\n            return 1\n        i = 0\n        j = i + 1\n        while j &lt; len(nums):\n            if nums[j] != nums[i]:\n                i += 1\n                nums[j], nums[i] = nums[i], nums[j]\n            j += 1\n        return i + 1\" style=\"color:#F8F8F2;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 dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">class<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">Solution<\/span><span style=\"color: #F8F8F2\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">def<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">removeDuplicates<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #BD93F9; font-style: italic\">self<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #FFB86C; font-style: italic\">nums<\/span><span style=\"color: #FF79C6\">:<\/span><span style=\"color: #F8F8F2\"> List[<\/span><span style=\"color: #8BE9FD; font-style: italic\">int<\/span><span style=\"color: #F8F8F2\">]) <\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD; font-style: italic\">int<\/span><span style=\"color: #F8F8F2\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">if<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">len<\/span><span style=\"color: #F8F8F2\">(nums) <\/span><span style=\"color: #FF79C6\">==<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            <\/span><span style=\"color: #FF79C6\">return<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        i <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        j <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> i <\/span><span style=\"color: #FF79C6\">+<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">while<\/span><span style=\"color: #F8F8F2\"> j <\/span><span style=\"color: #FF79C6\">&lt;<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">len<\/span><span style=\"color: #F8F8F2\">(nums):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            <\/span><span style=\"color: #FF79C6\">if<\/span><span style=\"color: #F8F8F2\"> nums[j] <\/span><span style=\"color: #FF79C6\">!=<\/span><span style=\"color: #F8F8F2\"> nums[i]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">                i <\/span><span style=\"color: #FF79C6\">+=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">                nums[j], nums[i] <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> nums[i], nums[j]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">            j <\/span><span style=\"color: #FF79C6\">+=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">return<\/span><span style=\"color: #F8F8F2\"> i <\/span><span style=\"color: #FF79C6\">+<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"16-code-explanation\">Code Explanation<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initial Checks:<\/strong>\n<ul class=\"wp-block-list\">\n<li>If the array has only one element, it immediately returns 1 since a single element is inherently unique.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Initialization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Two pointers, <strong>i<\/strong> and <strong>j<\/strong>, are initialized where <strong>i<\/strong> starts at <strong>0<\/strong> and <strong>j<\/strong> starts at <strong>i + 1<\/strong>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>While Loop:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The loop continues as long as <strong>j<\/strong> is less than the length of the array.<\/li>\n\n\n\n<li>Inside the loop:\n<ol class=\"wp-block-list\">\n<li>If <strong>nums[j]<\/strong> is different from <strong>nums[i]<\/strong>, this indicates a new unique element.<\/li>\n\n\n\n<li><strong>i<\/strong> is incremented to extend the segment of unique elements.<\/li>\n\n\n\n<li><strong>nums[j]<\/strong> is then swapped with <strong>nums[i]<\/strong>, positioning it within the unique segment.<\/li>\n\n\n\n<li><strong>j<\/strong> is incremented on every iteration to continue scanning the array.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Return Statement:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Returns <strong>i + 1<\/strong>, which is the count of unique elements since <strong>i <\/strong>is the index of the last unique element.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"17-dry-run-with-images\">Dry Run (with images)<\/h3>\n\n\n\n<p>Let&#8217;s walk through a step-by-step dry run with a sample input:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-1024x576.png\" alt=\"Dry run of optimal solution to remove duplicates from the array using two pointers\" class=\"wp-image-50\" srcset=\"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-1024x576.png 1024w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-300x169.png 300w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-768x432.png 768w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-1536x864.png 1536w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-150x84.png 150w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-450x253.png 450w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal-1200x675.png 1200w, https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-optimal.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"18-edge-cases-to-consider\">Edge cases to consider<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Empty Array:<\/strong> If nums is empty, our function will handle this and return 0.<\/li>\n\n\n\n<li><strong>All Elements Identical:<\/strong> For <strong>nums = [1, 1, 1]<\/strong>, our function should return <strong>1<\/strong>, correctly identifying the single unique element.<\/li>\n\n\n\n<li><strong>Array with No Duplicates:<\/strong> For an array like <strong>nums = [1, 2, 3]<\/strong>, our function should return the length of the array, which is <strong>3<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"19-time-and-space-complexity\">Time and Space Complexity<\/h3>\n\n\n\n<p><strong>Time Complexity:<\/strong> The complexity is <strong><em>O(n)<\/em><\/strong>, where <strong><em>n<\/em><\/strong> is the length of the array. Our code iterates through the list once with the <strong>j pointer<\/strong>.<\/p>\n\n\n\n<p><strong>Space Complexity:<\/strong> The complexity is <strong><em>O(1)<\/em><\/strong> as the solution modifies the array in place and does not use additional space.<\/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\/master-dsa-with-leetcode\" target=\"_blank\" rel=\"noreferrer noopener\">Join our FREE 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 document, kindly email at <a href=\"mailto:code@codeanddebug.in\">code@codeanddebug.in<\/a> or contact us at <a href=\"tel:+91-9712928220\">+91-9712928220<\/a>.<\/em><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone, in this article we&#8217;ll guide you through the Python program to Remove Duplicates from Soroted Array (in-place) [Problem Link]. We will see both the brute-force and optimal solution and dry run. So let&#8217;s begin. Understand the problem This problem &#8220;Remove Duplicates from Sorted Array&#8221; is about modifying a sorted array in place to<\/p>\n","protected":false},"author":1,"featured_media":51,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[7,8],"class_list":{"0":"post-47","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-array","10":"tag-easy"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/remove-duplicates-from-sorted-array-featured-image.jpg","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\/47","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=47"}],"version-history":[{"count":2,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions\/53"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/51"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}