// 20210131210952
// http://localhost:3000/all

[
  {
    "id": 1,
    "title": "Generate Parentheses",
    "slug": "generate-parentheses-13hd",
    "description": "Question number 22. Generate Parentheses  In this series, I am going to solve Leetcode medium problem...",
    "processed_html": "<p>Question number 22. Generate Parentheses<br>\n<a href=\"https://res.cloudinary.com/Optional/image/fetch/s--FheVkx9X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i83o2wl8riy6uk9ndtt2.png\" class=\"article-body-image-wrapper\"><img src=\"https://res.cloudinary.com/Optional/image/fetch/s--FheVkx9X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i83o2wl8riy6uk9ndtt2.png\" alt=\"Alt Text\" loading=\"lazy\"></a><br>\nIn this series, I am going to solve Leetcode medium problems live with my friends, which you can see on our youtube channel, Today we will do Problem Problem 22. Generate Parentheses.</p>\n\n<p>A little bit about me, I have offers from Uber India and Amazon India in the past, and I am currently working for Booking.com in Amsterdam.</p>\n<h2>\n  <a name=\"motivation-to-learn-algorithms\" href=\"#motivation-to-learn-algorithms\" class=\"anchor\">\n  </a>\n  Motivation to learn algorithms\n</h2>\n\n\n<div class=\"ltag__link\">\n  <a href=\"https://medium.com/leetcode-simplified/solve-leetcode-problems-and-get-offers-from-your-dream-companies-2786415be0b7\" class=\"ltag__link__link\">\n    <div class=\"ltag__link__pic\">\n      <img src=\"https://res.cloudinary.com/Optional/image/fetch/s--6IxRzTfm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/fit/c/96/96/1%2AhNjwft_dNBxvTr6g6TOVGg.jpeg\" alt=\"Nil Madhab\" loading=\"lazy\">\n    </div>\n  </a>\n  <a href=\"https://medium.com/leetcode-simplified/solve-leetcode-problems-and-get-offers-from-your-dream-companies-2786415be0b7\" class=\"ltag__link__link\">\n    <div class=\"ltag__link__content\">\n      <h2>Solve Leetcode Problems and Get Offers From Your Dream Companies | by Nil Madhab | LeetCode Simplified | Jan, 2021 | Medium</h2>\n      <h3>Nil Madhab ・ <time datetime=\"2021-01-25T13:36:09.910Z\">Jan 25, 2021</time> ・ 3 min read\n      <div class=\"ltag__link__servicename\">\n        <img src=\"/assets/medium_icon.svg\" alt=\"Medium Logo\" aria-label=\"Medium Logo\" loading=\"lazy\">\n        Medium\n      </div>\n    </h3>\n</div>\n  </a>\n</div>\n\n\n<h2>\n  <a name=\"problem-statement\" href=\"#problem-statement\" class=\"anchor\">\n  </a>\n  Problem Statement:\n</h2>\n\n<p>Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.</p>\n\n<p><strong>Example 1:</strong></p>\n\n<p><code>Input: n = 3<br>\nOutput: [\"((()))\",\"(()())\",\"(())()\",\"()(())\",\"()()()\"]</code></p>\n\n<p><strong>Example 2:</strong></p>\n\n<p><code>Input: n = 1<br>\nOutput: [\"()\"]</code></p>\n\n<p><strong>Constraints:</strong></p>\n\n<ul>\n<li>1 &lt;= n &lt;= 8</li>\n</ul>\n<h2>\n  <a name=\"youtube-discussion\" href=\"#youtube-discussion\" class=\"anchor\">\n  </a>\n  Youtube Discussion\n</h2>\n\n<p><iframe width=\"710\" height=\"399\" src=\"https://www.youtube.com/embed/zbUaPatPpvU\" allowfullscreen loading=\"lazy\">\n</iframe>\n</p>\n\n<h2>\n  <a name=\"solution\" href=\"#solution\" class=\"anchor\">\n  </a>\n  Solution\n</h2>\n\n<p>This is a backtracking problem. We have to generate all valid combinations of parentheses. First, we must identify what are the characteristics of a valid string. Their length should be 2*n, where n is the given number. Also, the order of the parenthesis is also important. We can only put opening parenthesis first and the no of opening and closing parenthesis should be same. Therefore we need to keep track of opening and closing parenthesis too.</p>\n\n<p>Therefore at first, we called the solve method with left and right value as 0 and empty string. We add an opening string to the string and call this method again with modified parameters. If it is not possible to add an opening parenthesis, we add one closing parenthesis and backtrack again. When we find the length of the string as 2*n we add that string to our global list. This can be understood with the dry run given in the code.</p>\n\n<p>The following is the Java code for this problem.</p>\n\n\n<div class=\"ltag_gist-liquid-tag\">\n  <script id=\"gist-ltag\" src=\"https://gist.github.com/sksaikia/b1e230841ba5bca299aab2803339354f.js\"></script>\n</div>\n\n\n<p>The C++ code is given below.</p>\n\n\n<div class=\"ltag_gist-liquid-tag\">\n  <script id=\"gist-ltag\" src=\"https://gist.github.com/sksaikia/21a731a0dbebb14abc834a840c4af7a4.js\"></script>\n</div>\n<br>\nThe code can be found in this repository.\n\n\n<div class=\"ltag-github-readme-tag\">\n  <div class=\"readme-overview\">\n    <h2>\n      <img src=\"/assets/github-logo.svg\" alt=\"GitHub logo\" loading=\"lazy\">\n      <a href=\"https://github.com/webtutsplus\">\n        webtutsplus\n      </a> / <a style=\"font-weight: 600;\" href=\"https://github.com/webtutsplus/LeetCode\">\n        LeetCode\n      </a>\n    </h2>\n    <h3>\n      \n    </h3>\n  </div>\n</div>\n\n\n<p><strong>Sign up for Leetcode Simplified</strong><br>\nBy LeetCode Simplified</p>\n\n<p>Get latest leetcode solution with youtube breakdown <a href=\"https://medium.com/leetcode-simplified/newsletters/leetcode-simplified?source=newsletter_v3_promo--------------------------newsletter_v3_promo-----------\">Take a look</a><br>\nYou're an editor of Leetcode Simplified</p>\n\n",
    "tag_list": [
      "algorithms",
      "coding"
    ]
  },
  {
    "id": 2,
    "title": "Solve Leetcode Problems | Remove All Adjacent Duplicates in String II",
    "slug": "solve-leetcode-problems-remove-all-adjacent-duplicates-in-string-ii-3j96",
    "description": "Problem 1209. Remove All Adjacent Duplicates in String II.  In this series, I am going to solve Leetc...",
    "processed_html": "<p>Problem 1209. <strong>Remove All Adjacent Duplicates in String II.</strong></p>\n\n<p>In this series, I am going to solve Leetcode medium problems live with my friend, which you can see on our youtube channel, Today we will do Problem 1209. <strong>Remove All Adjacent Duplicates in String II.</strong></p>\n\n<p>A little bit about me, I have offers from <strong>Uber India</strong> and <strong>Amazon India</strong> in the past, and I am currently working for <strong>Booking.com</strong> in Amsterdam.</p>\n\n<p><a href=\"https://res.cloudinary.com/Optional/image/fetch/s--DIMl_j8U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s5bkah60kdlzj704s68t.jpg\" class=\"article-body-image-wrapper\"><img src=\"https://res.cloudinary.com/Optional/image/fetch/s--DIMl_j8U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s5bkah60kdlzj704s68t.jpg\" alt=\"Alt Text\" loading=\"lazy\"></a></p>\n\n<h2>\n  <a name=\"youtube-discussion\" href=\"#youtube-discussion\" class=\"anchor\">\n  </a>\n  Youtube Discussion\n</h2>\n\n<p>Please comment here or on youtube, if you have any doubts<br>\n<iframe width=\"710\" height=\"399\" src=\"https://www.youtube.com/embed/XZZL_nJ21VU\" allowfullscreen loading=\"lazy\">\n</iframe>\n</p>\n\n<h2>\n  <a name=\"motivation-to-learn-algorithms\" href=\"#motivation-to-learn-algorithms\" class=\"anchor\">\n  </a>\n  Motivation to Learn Algorithms\n</h2>\n\n<p>I have worked in India as a software developer for 4 years. I started learning algorithms and data structure from my 3rd year in college as I was from an Electronics background. Here is my salary progression over the years, (all in INR, Lakh per year)</p>\n\n<p>2016: placement in <strong>Flipkart</strong> from college, IIT KGP(18 lakh base + 2 lakh bonus = <strong>20</strong> lakh). But the offer was delayed by 6 months, as Flipkart was going through some trouble, so I joined Samsung.</p>\n\n<p>2016: <strong>Samsung Noida</strong>(off campus ) (14 lakh base + 5 lakh joining bonus = <strong>19</strong> lakh). They pay to IITians 19 lakh but other colleges 9-14 lakh for the same work, which is bogus.</p>\n\n<p>2017: <strong>Oyorooms</strong> (<strong>17</strong> lakh fixed, no bonus, no stocks). I took a pay cut as I was not learning anything in Samsung, so joined Oyo.</p>\n\n<p>2019: <strong>Sharechat</strong> (26 lakh fixed + 2.6lakh bonus + stock options) I joined Sharechat in Bangalore, as SDE1 , I also got offers from <strong>Grab</strong> (21 lakh fixed + 3 lakh bonus =<strong>24 lakh</strong>) and <strong>Rivigo</strong> (27 lakh fixed+3 lakh bonus = <strong>30 lakh</strong>).</p>\n\n<p>2020: Offer from Amazon ( 26.5 lakh base + 18.5 lakh joining bonus= <strong>43 lakh</strong>) in SDE2 role. They offer stocks but it is vested only 5 percent in the first year, so I ignored it.</p>\n\n<p>Offer from <strong>Uber</strong> (33 lakh base + 15 lakh stock options per year (96000 USD over 4 years)+ 5 lakh joining bonus = <strong>55</strong> lakh per year) in SDE2 role. <strong>I think that is the top salary, you can get 3.5–4 years experience in India, but I might be wrong.</strong><br>\n</p>\n<div class=\"ltag_gist-liquid-tag\">\n  <script id=\"gist-ltag\" src=\"https://gist.github.com/sksaikia/b3e44a32bab220f3773ca25ba9b9adf2.js\"></script>\n</div>\n<br>\nI rejected both offers and ended up joining <strong>Booking.com</strong> as I wanted to explore Europe. I can’t disclose my current salary.\n\n<p><code>A lot of startups and established companies in India pay over 35 lakh per year for the top talent in programming, for just over 4 years of experience, like Dunzo, Dream11, Rubric, etc, check</code></p>\n\n<p><a href=\"https://leetcode.com/discuss/compensation\">Compensation</a></p>\n\n<p>Even if you are not from a good college, you can still land awesome jobs, for let’s take this example</p>\n\n<p><code><br>\nEducation: B.Tech in CS from Tier 3 college<br>\nYears of Experience: 2<br>\nPrior Experience: Java Developer at Startup<br>\ncurrent CTC: INR 3.2 LPA+1 LPA(Bonus)<br>\nDate of the Offer:Dec 2020<br>\nCompany: Swiggy<br>\nTitle/Level:SDE -1<br>\nLocation: Bangalore<br>\nSalary: INR 17.6 LPA<br>\nRelocation/Signing Bonus: -<br>\nStock bonus: 7 LPA vested over 4 years<br>\nBonus: -<br>\nTotal comp (Salary + Bonus + Stock): 17.6 + 0 + 1.75 =INR 19.35 LPA<br>\nBenefits: -<br>\nOther details: Not even a single word from me after this digits are spoken by the recruiter.<br>\n</code><br>\n<strong>Has a 6 months career gap even at the time of offer</strong></p>\n\n<p>I got so many offers because I practiced a lot of data structure and algorithms. I solved over 410 questions in Leetcode.</p>\n\n<p><a href=\"https://leetcode.com/nilmadhab/\">Nil Madhab-Leetcode Profile</a></p>\n<h2>\n  <a name=\"problem-statement\" href=\"#problem-statement\" class=\"anchor\">\n  </a>\n  Problem statement:\n</h2>\n\n<p>Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together.</p>\n\n<p>We repeatedly make k duplicate removals on s until we no longer can.</p>\n\n<p>Return the final string after all such duplicate removals have been made.</p>\n\n<p>It is guaranteed that the answer is unique.</p>\n\n<p><strong>Example 1:</strong></p>\n\n<p><code>Input: s = \"abcd\", k = 2<br>\nOutput: \"abcd\"<br>\nExplanation: There's nothing to delete.</code></p>\n\n<p><strong>Example 2:</strong></p>\n\n<p><code>Input: s = \"deeedbbcccbdaa\", k = 3<br>\nOutput: \"aa\"<br>\nExplanation:<br>\nFirst delete \"eee\" and \"ccc\", get \"ddbbbdaa\"<br>\nThen delete \"bbb\", get \"dddaa\"<br>\nFinally delete \"ddd\", get \"aa\"</code></p>\n\n<p><strong>Example 3:</strong></p>\n\n<p><code>Input: s = \"pbbcggttciiippooaais\", k = 2<br>\nOutput: \"ps\"</code></p>\n<h2>\n  <a name=\"solution\" href=\"#solution\" class=\"anchor\">\n  </a>\n  Solution\n</h2>\n\n<p>This problem can be solved by using a stack. If we count the occurrence of each character and store it in a stack and as soon as the occurrence of that character becomes equal to k, we remove it from the stack. As we have stored the characters and their occurrence in a stack, we can pop it from the stack and reverse the generated string from the stack. (Reversal is necessary, just to a dry run of example 4).</p>\n\n<p>The java code along with a dry run of example 3 for this problem is given below.<br>\n</p>\n<div class=\"ltag_gist-liquid-tag\">\n  <script id=\"gist-ltag\" src=\"https://gist.github.com/sksaikia/9b5a74ae09769ce5cd42b4473cc4e6bd.js\"></script>\n</div>\n\n\n<p>The python code is given below.</p>\n\n\n<div class=\"ltag_gist-liquid-tag\">\n  <script id=\"gist-ltag\" src=\"https://gist.github.com/sksaikia/cb80d916ccea8415855da834772ca016.js\"></script>\n</div>\n\n\n<p>Time Complexity: O(n), n is the length of the string</p>\n\n<p>Space Complexity: O(n), n is the length of the string</p>\n\n<p>The solution code can be found in this repository.</p>\n\n\n<div class=\"ltag-github-readme-tag\">\n  <div class=\"readme-overview\">\n    <h2>\n      <img src=\"/assets/github-logo.svg\" alt=\"GitHub logo\" loading=\"lazy\">\n      <a href=\"https://github.com/webtutsplus\">\n        webtutsplus\n      </a> / <a style=\"font-weight: 600;\" href=\"https://github.com/webtutsplus/LeetCode\">\n        LeetCode\n      </a>\n    </h2>\n    <h3>\n      \n    </h3>\n  </div>\n</div>\n\n\n",
    "tag_list": [
      "algorithms",
      "programming",
      "career",
      "computerscience"
    ]
  }
]