<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: abhsiksah</title>
    <description>The latest articles on DEV Community by abhsiksah (@abhsiksah).</description>
    <link>https://dev.to/abhsiksah</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F620592%2F8b5768e9-7860-44fd-8e9a-a10efea91450.jpeg</url>
      <title>DEV Community: abhsiksah</title>
      <link>https://dev.to/abhsiksah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhsiksah"/>
    <language>en</language>
    <item>
      <title>Dry running the code to understand the flow</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Sat, 27 Apr 2024 11:29:03 +0000</pubDate>
      <link>https://dev.to/abhsiksah/dry-running-the-code-to-understand-the-flow-4gmj</link>
      <guid>https://dev.to/abhsiksah/dry-running-the-code-to-understand-the-flow-4gmj</guid>
      <description>&lt;p&gt;So I am trying to solve a problem in recursion and backtracking using js as my language. the question is :&lt;/p&gt;

&lt;p&gt;` Subsets ( Backtracking Algorithm using Recursion )&lt;br&gt;
// Given an integer array nums of unique elements, return all possible subsets (the power set).&lt;br&gt;
// The solution set must not contain duplicate subsets. Return the solution in any order.&lt;/p&gt;

&lt;p&gt;// Input: [1,2,3]  -----&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]&lt;br&gt;
// Input: [0]      -----&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  Output: [[],[0]]`&lt;/p&gt;

&lt;p&gt;My Solution&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function subsets(prob) {
  let result = [];
  let temp = [];

  function getPowSet(nums, i) {
    if (i === nums.length) {
      return result.push([...temp]);
    }
    console.log(temp, i, "0");
    temp.push(nums[i]);
    getPowSet(nums, i + 1);
    console.log(temp, i, "1");
    temp.pop();
    getPowSet(nums, i + 1);
    console.log(temp, i, "2");
  }
  getPowSet(prob, 0);
  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and I have put certain logs in the code to understand the flow&lt;/p&gt;

&lt;p&gt;the logs looks like:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 1 ] 0 0
[ 1, 2 ] 1 0
[ 1, 2, 3 ] 2 0
[ 1, 2 ] 2 1
[ 1, 2 ] 2 2
[ 1 ] 1 1
[ 1, 3 ] 2 0
[ 1 ] 2 1
[ 1 ] 2 2
[ 1 ] 1 2
[] 0 1
[ 2 ] 1 0
[ 2, 3 ] 2 0
[ 2 ] 2 1
[ 2 ] 2 2
[] 1 1
[ 3 ] 2 0
[] 2 1
[] 2 2
[] 1 2
[] 0 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My concern:&lt;/p&gt;

&lt;p&gt;So when the code completes its 1st recursion loop and hits the base case when i become 3 and pushes the temp array to result and returns.. why does the i still logs as 2 in the next log, because there is no i-- going on anywhere inside the base case so it should still log i = 3 &lt;/p&gt;

&lt;p&gt;here :-&lt;/p&gt;

&lt;p&gt;[ 1 ] 0 0&lt;br&gt;
[ 1, 2 ] 1 0&lt;br&gt;
[ 1, 2, 3 ] 2 0&lt;br&gt;
[ 1, 2 ] 2 1     &amp;lt;--------&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>recursion</category>
      <category>backtracking</category>
    </item>
    <item>
      <title>Free 1:1 connect for Jr. FrontEnd developers</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Fri, 16 Jun 2023 05:58:23 +0000</pubDate>
      <link>https://dev.to/abhsiksah/free-11-connect-for-jr-frontend-developers-5gml</link>
      <guid>https://dev.to/abhsiksah/free-11-connect-for-jr-frontend-developers-5gml</guid>
      <description>&lt;p&gt;if interested please click on the link below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://topmate.io/abhishek_sah10"&gt;https://topmate.io/abhishek_sah10&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>WHY is this not showing 123???</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Fri, 04 Nov 2022 14:10:31 +0000</pubDate>
      <link>https://dev.to/abhsiksah/why-is-this-not-showing-123-3509</link>
      <guid>https://dev.to/abhsiksah/why-is-this-not-showing-123-3509</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var status = 23;

function yzx() {
  var status = 123;

  xyz = () =&amp;gt; {
    setTimeout(() =&amp;gt; {
      console.log(this.status);
    }, 100);
  };
  xyz();
}
yzx();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>this</category>
      <category>logical</category>
    </item>
    <item>
      <title>Children prop in React!!!</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Sun, 01 Aug 2021 08:25:42 +0000</pubDate>
      <link>https://dev.to/abhsiksah/children-prop-in-react-14g</link>
      <guid>https://dev.to/abhsiksah/children-prop-in-react-14g</guid>
      <description>&lt;p&gt;Refer this below:&lt;br&gt;
&lt;a href="https://www.netlify.com/blog/2020/12/17/react-children-the-misunderstood-prop/"&gt;https://www.netlify.com/blog/2020/12/17/react-children-the-misunderstood-prop/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Looking for a nice react developer for freelancing in India!!</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Sun, 25 Jul 2021 12:59:56 +0000</pubDate>
      <link>https://dev.to/abhsiksah/looking-for-a-nice-react-developer-for-freelancing-in-india-35da</link>
      <guid>https://dev.to/abhsiksah/looking-for-a-nice-react-developer-for-freelancing-in-india-35da</guid>
      <description>&lt;p&gt;Anyone Interested please contact me on 9962258240&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Power of JS: reduce</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Sat, 08 May 2021 14:22:16 +0000</pubDate>
      <link>https://dev.to/abhsiksah/power-of-js-reduce-22f1</link>
      <guid>https://dev.to/abhsiksah/power-of-js-reduce-22f1</guid>
      <description>&lt;p&gt;//  You will be given an array of several arrays that each contain integers and your goal is to write a function that will sum up all the numbers &lt;br&gt;
// in all the arrays. For example, if the input is [[3, 2], [1], [4, 12]] then your program should output 22 because 3 + 2 + 1 + 4 + 12 = 22. &lt;br&gt;
// Solve without and with reduce.&lt;/p&gt;

&lt;p&gt;//without reduce&lt;/p&gt;

&lt;p&gt;const sumofsubarray = (arr) =&amp;gt;{&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let result = 0;
arr.map((elem)=&amp;gt;{

// console.log(elem)
elem.map((eleme)=&amp;gt;{

    result+=eleme;
})


})

return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;// console.log(sumofsubarray([[3, 2], [1], [4, 12]]))&lt;/p&gt;

&lt;p&gt;//with reduce function&lt;/p&gt;

&lt;p&gt;const arr = [[3, 2], [1], [4, 12]]&lt;/p&gt;

&lt;p&gt;console.log(arr.reduce((t,e)=&amp;gt;t.concat(e)).reduce((t,e)=&amp;gt;t+e))&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>So I came across this question.....</title>
      <dc:creator>abhsiksah</dc:creator>
      <pubDate>Thu, 06 May 2021 17:50:00 +0000</pubDate>
      <link>https://dev.to/abhsiksah/so-i-came-across-this-question-mnd</link>
      <guid>https://dev.to/abhsiksah/so-i-came-across-this-question-mnd</guid>
      <description>&lt;p&gt;Given two strings, return true if they are one edit away from each other, else return false.&lt;/p&gt;

&lt;p&gt;and this is my solution but I cannot get my answer:&lt;/p&gt;

&lt;p&gt;//code:&lt;/p&gt;

&lt;p&gt;const isobj = (str) =&amp;gt; {&lt;br&gt;
    let obj = {};&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (const char of str) {
    !obj[char] ? (obj[char] = 1) : obj[char]++;
}

return obj;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;const isedit = (str1, str2) =&amp;gt; {&lt;br&gt;
    let obj1 = isobj(str1);&lt;br&gt;
    let obj2 = isobj(str2);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// console.log(obj1,obj2)
let counter = 0;


for (let key in obj2) {
    if (obj1[key] == obj2[key]) 
    {
        continue;
    }
    else {
        if (obj1[key] - obj2[key] == 1) 
        {
            counter++;
        } else
        {
            return false;
        }
    }
}
  console.log(counter);

if (counter == 1) {
    return true;
} else {
    return false;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;console.log(isedit("pal", "pale"));&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
