<?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: Sourav </title>
    <description>The latest articles on DEV Community by Sourav  (@sksaikia).</description>
    <link>https://dev.to/sksaikia</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%2F589202%2Fd4a8b7ea-2a91-4748-8526-f944386b2bf3.jpeg</url>
      <title>DEV Community: Sourav </title>
      <link>https://dev.to/sksaikia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sksaikia"/>
    <language>en</language>
    <item>
      <title>Retrieve Vaccine Slots in your locality (Python Web-Scrapping)</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Sun, 23 May 2021 15:53:27 +0000</pubDate>
      <link>https://dev.to/sksaikia/retrieve-vaccine-slots-in-your-locality-python-web-scrapping-23o0</link>
      <guid>https://dev.to/sksaikia/retrieve-vaccine-slots-in-your-locality-python-web-scrapping-23o0</guid>
      <description>&lt;p&gt;I know it is hard to get a vaccine slot. I have been trying to get a slot for the last two weeks; still have not got it. Therefore I decided to make a python script that will notify me about the vaccination slots.&lt;/p&gt;

&lt;p&gt;For this, we will use the APIs provided by our Indian Government and scrap the page. If you try to do a lot of requests to the server, your IP address may be blocked. BEWARE!!!!!!!!!!!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Web Scraping&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web scraping&lt;/strong&gt; is the process of using bots to extract content and data from a website.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Cowin-API&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can check the APIs from this page. (&lt;a href="https://apisetu.gov.in/public/marketplace/api/cowin#/Appointment%20Availability%20APIs/calendarByPin"&gt;Link&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Let’s have a look at the response for the network which we are going to make. We have to create a model to extract that information.&lt;/p&gt;

&lt;p&gt;Demo API call: &lt;a href="https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=110001&amp;amp;date=23-05-2021"&gt;https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=110001&amp;amp;date=23-05-2021&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ch2S5NJX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3834/1%2AwqVgXl6bLD2OeNKitY4VZA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ch2S5NJX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3834/1%2AwqVgXl6bLD2OeNKitY4VZA.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have to find the available_capacity field for each session in each centre.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Coding part&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First, install the requests and plyer library.&lt;/p&gt;

&lt;p&gt;pip install requests and pip install plyer&lt;/p&gt;

&lt;p&gt;Import these libraries, they will be needed. requests is used to make HTTP requests, plyer is used to send desktop notifications. time and datetime are used to handle date-time related things, need to convert them into appropriate formats.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
import time
from datetime import datetime,timedelta
from plyer import notification
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now, we will define some parameters which will be used for searching. You have to enter the age, pin codes and the number of days you want to search for. The API allows us to search for availability for the next 7 days.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_age = 55
pincodes=["782411","782410"]
num_days = 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We also have to convert to the dates into a suitable format so that we can make the API call. We extract today’s date from datetime and convert the next num_days accordingly.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;actual = datetime.today()
list_format = [actual + timedelta(days=i) for i in range(num_days)]
actual_dates = [i.strftime("%d-%m-%Y") for i in list_format]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now comes the main part. We have to search for all the pincodes for all the given dates. Also, the search is needed to be done for all the centres for all the sessions. If any conditions are satisfied, then we will print that result. That result will be sent as a notification to the desktop. After the search is completed, we will wait for 5 minutes (use sleep function) and continue searching again.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(True) :
    availbleCenters = 0

    #We have to search for all pincodes for all the given dates
    for pincode in pincodes:
        for date in actual_dates:
            #The API to hit for our operation
            URL = f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={pincode}&amp;amp;date={date}"
            header = {
                'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'}

            result = requests.get(URL, headers=header)
            #If the response is 200 then proceed
            if result.ok:
                response_json = result.json()
                #We have to search for available capacity in each session for each center
                for center in response_json['centers']:
                    for session in center['sessions']:
                        #If the condition is satisfied like the available capacity is not zero and age limit is also satisfied then print them
                        if (session['available_capacity']&amp;gt;0 and session['min_age_limit']&amp;lt;=user_age and session["date"] == date ):
                            availbleCenters = availbleCenters+1
                            print('Center Name : ' , center['name'])
                            print('Available slots : ' , session['available_capacity'])
                            print('Pincode : ' , pincode)
                            print('Vaccine Name : ' , session['vaccine'])
                            print('Date : ', session['date'])
                            print('----------------------------------')

                            centerName = center['name']
                            availbleSlots = session['available_capacity']
                            dateOfSlot = session['date']
                            vaccineName = session['vaccine']
                            #plyer is used here to notify people in desktop.
                            notification.notify(
                                title="Vaccine Slots Availble",
                                # the body of the notification
                                message=f"Center Name : {centerName} \n Availble slots : {availbleSlots} \n Vaccine Name : {vaccineName} \n Date : {dateOfSlot}",
                                #You can add a icon here also in the .ico format
                                # the notification stays for 5sec
                                timeout=5
                            )


            else:
                print("No Response")

    if availbleCenters==0:
        print("No availble slots in these areas...")
        notification.notify(
            title="No Vaccine Slots are available",
            # the body of the notification
            message="Sorry, there is no available slot in your area",
            # You can add a icon here also in the .ico format
            # the notification stays for 5sec
            timeout=5
        )
    else:
        print(f"Hurray. Found {availbleCenters} results...")
    #The process will resume after 300 seconds. That means we will make the APi call again after 5 minutes.
    time.sleep(300)
    print("Waited for 5 minutes. Start searching again")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After you run this script, you will receive notifications every 5 minutes if there is any available slot in your area. Hurray!!!!! We have completed the work.&lt;/p&gt;

&lt;p&gt;The notification will be shown like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BBpR3CMD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2A-A72drZD0pHBpcuxd_aKhA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BBpR3CMD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2A-A72drZD0pHBpcuxd_aKhA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The results will also be printed on the console just like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEYLfp6d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2906/1%2A3XtaC06X2bvgwTC7MBe88w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEYLfp6d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2906/1%2A3XtaC06X2bvgwTC7MBe88w.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If there is no available slot in those pin codes, you will receive “NO RESPONSE” on the console. You will receive a notification stating no vaccine slots available. You can easily tweak the time for notifications.pincodes and days. Go ahead and play with it.&lt;/p&gt;

&lt;p&gt;The complete work can be found here.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/Cowin-Notifier"&gt;
        Cowin-Notifier
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Cowin-Notifier&lt;/h1&gt;
&lt;p&gt;This is a python script which can notify you about vaccination available slots. It uses the API provided by CoWIN and fetches available slots for vaccination. You can input your pincodes(multiple) and number of days you want to fetch and it will notify you about the slots.
Pincode, number of days and search time can be changed from the script.&lt;/p&gt;
&lt;h2&gt;
Full Setup Guide&lt;/h2&gt;
&lt;p&gt;You have to install multiple packages for it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install requests (Used for make HTTP requests)
&lt;div class="snippet-clipboard-content position-relative"&gt;&lt;pre&gt;&lt;code&gt;pip install requests
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Install Plyer (Used for sending desktop notifications)
&lt;div class="snippet-clipboard-content position-relative"&gt;&lt;pre&gt;&lt;code&gt;pip install plyer 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can find the full tutorial &lt;a href="https://sourav-saikia.medium.com/retrieve-vaccine-slots-in-your-locality-python-web-scrapping-e0005c42c5b0" rel="nofollow"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/Cowin-Notifier"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
      <category>python</category>
      <category>codenewbie</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>MayLeetCoding Challenge 2021 — Day 4: Non-decreasing Array</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Tue, 04 May 2021 13:37:21 +0000</pubDate>
      <link>https://dev.to/sksaikia/mayleetcoding-challenge-2021-day-4-non-decreasing-array-1en7</link>
      <guid>https://dev.to/sksaikia/mayleetcoding-challenge-2021-day-4-non-decreasing-array-1en7</guid>
      <description>&lt;p&gt;Today is May the 4th. Happy Star Wars Day everyone.&lt;/p&gt;

&lt;p&gt;Let’s solve some Leetcode problems today. Today we will solve the 4th problem of the May LeetCoding Challenge 2021.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4SvXyyH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2AyQ4kMPjosBcBVqGSSkI7Zw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4SvXyyH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2AyQ4kMPjosBcBVqGSSkI7Zw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying &lt;strong&gt;at most one element&lt;/strong&gt;.
&lt;/h2&gt;

&lt;p&gt;We define an array is non-decreasing if nums[i] &amp;lt;= nums[i + 1] holds for every i (&lt;strong&gt;0-based&lt;/strong&gt;) such that (0 &amp;lt;= i &amp;lt;= n - 2).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [4,2,3]
**Output:** true
**Explanation:** You could modify the first 4 to 1 to get a non-decreasing array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [4,2,1]
**Output:** false
**Explanation:** You can't get a non-decreasing array by modify at most one element.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;We are going to solve this problem greedily. We can modify at array at max 1 time so that it becomes a non-decreasing array.&lt;/p&gt;

&lt;p&gt;To achieve that, we have to take care of few things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When modifying the number at index i-1 , we need to consider elements at i-2 and i -th index.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Need to make sure that the array satisfies the conditions even after modifications are made.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Correction can be made in either of two ways&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make the previous number smaller or equal to the current number&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the current number equal to the previous number&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can do the first as long as the number at position i-2is equal or lower than the current element(index i),if i-2is valid. If we can’t then go for the second condition. We give priority to the first case.&lt;/p&gt;

&lt;p&gt;Check the code below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Time complexity:O(n)&lt;/p&gt;

&lt;p&gt;Space complexity:O(1)&lt;/p&gt;

&lt;p&gt;Check the whole repository for more leetcode solutions.&lt;br&gt;
&lt;a href="https://github.com/sksaikia/LeetCode"&gt;&lt;strong&gt;sksaikia/LeetCode&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
    <item>
      <title>MayLeetCoding Challenge 2021 — Day 3: Minimum Operations to Make Array Equal</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Tue, 04 May 2021 13:35:00 +0000</pubDate>
      <link>https://dev.to/sksaikia/mayleetcoding-challenge-2021-day-3-minimum-operations-to-make-array-equal-1h3k</link>
      <guid>https://dev.to/sksaikia/mayleetcoding-challenge-2021-day-3-minimum-operations-to-make-array-equal-1h3k</guid>
      <description>&lt;p&gt;Today, we will solve the 3rd problem of the May LeetCoding Challenge 2021.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).&lt;/p&gt;

&lt;p&gt;Return the running sum of nums.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [1,2,3,4]
**Output:** [1,3,6,10]
**Explanation:** Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [1,1,1,1,1]
**Output:** [1,2,3,4,5]
**Explanation:** Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [3,1,2,10,1]
**Output:** [3,4,6,16,17]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;This is a pretty easy problem. Here we have to find the running sum of an array. That means, for index i we have to find the sum of all elements from 0 to i-1 . It can be done by using sum variable to store the summation of each element index by index.&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Time complexity: O(n)&lt;/p&gt;

&lt;p&gt;Space complexity: O(n)&lt;/p&gt;

&lt;p&gt;where n is the size of the array&lt;/p&gt;

&lt;p&gt;For the whole repository click the link below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Design Authentication Manager&lt;/td&gt;
&lt;td&gt;1797&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>April LeetCoding Challenge 2021 — Day 6: Minimum Operations to Make Array Equal</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Tue, 06 Apr 2021 20:20:08 +0000</pubDate>
      <link>https://dev.to/sksaikia/april-leetcoding-challenge-2021-day-6-minimum-operations-to-make-array-equal-1d20</link>
      <guid>https://dev.to/sksaikia/april-leetcoding-challenge-2021-day-6-minimum-operations-to-make-array-equal-1d20</guid>
      <description>&lt;p&gt;Today, we will solve the 6th problem of the April LeetCoding Challenge 2021.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 &amp;lt;= i &amp;lt; n).&lt;/p&gt;

&lt;p&gt;In one operation, you can select two indices x and y where 0 &amp;lt;= x, y &amp;lt; n and subtract 1 from arr[x] and add 1 to arr&lt;a href="//i.e.%20perform%20arr%5Bx%5D%20-=1%20and%20arr%5By%5D%20+=%201"&gt;y&lt;/a&gt;. The goal is to make all the elements of the array &lt;strong&gt;equal&lt;/strong&gt;. It is &lt;strong&gt;guaranteed&lt;/strong&gt; that all the elements of the array can be made equal using some operations.&lt;/p&gt;

&lt;p&gt;Given an integer n, the length of the array. Return &lt;em&gt;the minimum number of operations&lt;/em&gt; needed to make all the elements of arr equal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** n = 3
**Output:** 2
**Explanation:** arr = [1, 3, 5]
First operation choose x = 2 and y = 0, this leads arr to be [2, 3, 4]
In the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** n = 6
**Output:** 9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;This is a basic problem. Here we have to make all the elements of the array equal by a particular operation. We have to find the minimum number of steps to make the array elements equal.&lt;/p&gt;

&lt;p&gt;To do this task in minimum steps, we can convert the elements into their mean value.&lt;/p&gt;

&lt;p&gt;According to the question, the elements at i-th index is (2*i)+1 . Therefore the mean of these elements will be n ,which is given in the question.&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;/p&gt;



&lt;p&gt;The code can be found here&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Design Authentication Manager&lt;/td&gt;
&lt;td&gt;1797&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>April LeetCoding Challenge 2021 — Day 1: Palindrome Linked List</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Thu, 01 Apr 2021 20:33:48 +0000</pubDate>
      <link>https://dev.to/sksaikia/april-leetcoding-challenge-2021-day-1-palindrome-linked-list-4625</link>
      <guid>https://dev.to/sksaikia/april-leetcoding-challenge-2021-day-1-palindrome-linked-list-4625</guid>
      <description>&lt;p&gt;From today, we will start doing the April LeetCoding Challenge. You can check the March LeetCoding Challenge problems on my profile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given the head of a singly linked list, return true if it is a palindrome.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Af-n2TaPR7PhAzqqu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Af-n2TaPR7PhAzqqu.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1,2,2,1]
**Output:** true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALnbhl2I8Yx0tiOBV.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ALnbhl2I8Yx0tiOBV.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1,2]
**Output:** false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The number of nodes in the list is in the range [1, 105].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0 &amp;lt;= Node.val &amp;lt;= 9&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Follow up:&lt;/strong&gt; Could you do it in O(n) time and O(1) space?&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Solution&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this problem, we have to find whether a given LinkedList is palindrome or not. I hope you know what a Palindrome is. (&lt;a href="https://computersciencewiki.org/index.php/Palindrome#:~:text=A%20palindrome%20is%20a%20word,racecar%2C%20or%20the%20number%2010801.&amp;amp;text=The%20output%20should%20be%20%22True,it%20is%20not%20a%20palindrome." rel="noopener noreferrer"&gt;Check here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;We are going to discuss two approaches to this problem.&lt;/p&gt;

&lt;p&gt;Approach 1: Using ArrayList: The basic idea behind this approach is to store all the node values in an ArrayList. After that, we traverse the list for start and end, and keep comparing the values at start index and end index. If they are equal then increase start index and decrease end index. If two values are not the same, then we return &lt;strong&gt;false&lt;/strong&gt;(the LinkedList is not a palindrome).&lt;/p&gt;



&lt;p&gt;Time Complexity:O(n), for traversing the LinkedList&lt;/p&gt;

&lt;p&gt;Space Complexity:O(n), using ArrayList for storing the node values&lt;/p&gt;

&lt;p&gt;Approach 2: In this method, we will use LinkedList manipulations.&lt;/p&gt;

&lt;p&gt;If the length of the LinkedList is even :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Find the middle point of the LinkedList.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reverse the second half.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the reverse list to the first half of the list, if all the values are equal return true else return false&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AhCEthll7UYCnr45R_W8IvA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AhCEthll7UYCnr45R_W8IvA.png" alt="Diagram representing LinkedList with even number of nodes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the length of the LinkedList is odd:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Find the middle point of the LinkedList. As the length is odd, the middle point will be between the first half and second half of the LinkedList.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now reverse the second half of the Linked List&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the reverse list to the first half of the list, if all the values are equal return true else return false&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AS6ePH7JZKJJY0SKbqS-wEw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2560%2F1%2AS6ePH7JZKJJY0SKbqS-wEw.png" alt="Diagram representing LinkedList with odd number of nodes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;/p&gt;



&lt;p&gt;Time Complexity:O(n), for traversing the LinkedList&lt;/p&gt;

&lt;p&gt;Space Complexity:O(1), No additional space is used&lt;/p&gt;

&lt;p&gt;The code can be found here&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia" rel="noopener noreferrer"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode" rel="noopener noreferrer"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Leetcode solutions in java. Problems are divided by problem number (i.e 1-100, 101-200 etc.)  . This repository contains more than 300 problem solutions
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;LeetCode&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow noopener noreferrer"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow noopener noreferrer"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Design Authentication Manager&lt;/td&gt;
&lt;td&gt;1797&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/leetcode-1797-design-authentication-manager-biweekly-contest-48-8ef4d82a220d&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;March LeetCoding Challenge&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow noopener noreferrer"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow noopener noreferrer"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow noopener noreferrer"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>codequality</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 19: Keys and Rooms</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Sat, 20 Mar 2021 07:46:17 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-19-keys-and-rooms-51bl</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-19-keys-and-rooms-51bl</guid>
      <description>&lt;p&gt;Today, we will solve the 19th problem of the March LeetCoding Challenge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_B9cI61g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2A7U-VncFhXIrpCdpzAiIhOw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_B9cI61g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2A7U-VncFhXIrpCdpzAiIhOw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room.&lt;/p&gt;

&lt;p&gt;Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length. A key rooms[i][j] = v opens the room with number v.&lt;/p&gt;

&lt;p&gt;Initially, all the rooms start locked (except for room 0).&lt;/p&gt;

&lt;p&gt;You can walk back and forth between rooms freely.&lt;/p&gt;

&lt;p&gt;Return true if and only if you can enter every room.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input: **[[1],[2],[3],[]]
**Output: **true
**Explanation:  **
We start in room 0, and pick up key 1.
We then go to room 1, and pick up key 2.
We then go to room 2, and pick up key 3.
We then go to room 3.  Since we were able to go to every room, we return true.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input: **[[1,3],[3,0,1],[2],[0]]
**Output: **false
**Explanation: **We can't enter the room with number 2.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;1 &amp;lt;= rooms.length &amp;lt;= 1000&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0 &amp;lt;= rooms[i].length &amp;lt;= 1000&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The number of keys in all rooms combined is at most 3000.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In this problem, we have to find whether we can visit all the rooms. Initially, the 0-th room is opened, and at every index, we have the keys to go to other rooms. So, we can visualize this problem as a graph-based problem.&lt;/p&gt;

&lt;p&gt;Once we enter the 0-th room, we will check for keys in that room. Once we find a key, we directly move to that room and repeat the process. We keep the count of visited rooms in a HashSet. If the size of the HashSet is equal to the number of rooms, we return true else false. We are using breath-first-search to solve this problem.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
The code can be found here&lt;br&gt;&lt;/p&gt;

&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Check out my other posts on March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6 — Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://levelup.gitconnected.com/leetcode-706-design-hashmap-march-leetcoding-challenge-2021-fdae1a4adbc"&gt;March LeetCoding Challenge — Day 7 — Design HashMap&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-8-remove-palindromic-subsequences-12b037705722"&gt;March LeetCoding Challenge — Day 8 — Remove Palindromic Subsequences&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-10-integer-to-roman-76caa87a0e07"&gt;March LeetCoding Challenge — Day 10 — Integer to Roman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-48f1fed4d9b9"&gt;March LeetCoding Challenge — Day 12 — Check If a String Contains All Binary Codes of Size K&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-14-swapping-nodes-in-a-linked-list-a540785c816f"&gt;March LeetCoding Challenge — Day 14 — Swapping Nodes in a Linked List&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-15-encode-and-decode-tinyurl-bfeeba44308e"&gt;March LeetCoding Challenge — Day 15 — Encode and Decode TinyURL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-18-wiggle-subsequence-3c408287325b"&gt;March LeetCoding Challenge — Day 18 — Wiggle Subsequence&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 18: Wiggle Subsequence</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Thu, 18 Mar 2021 15:24:31 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-18-wiggle-subsequence-3ng</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-18-wiggle-subsequence-3ng</guid>
      <description>&lt;p&gt;Today, we will solve the 18th problem of the March LeetCoding Challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given an integer array nums, return &lt;em&gt;the length of the longest **wiggle sequence&lt;/em&gt;**.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;wiggle sequence&lt;/strong&gt; is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For example, [1, 7, 4, 9, 2, 5] is a &lt;strong&gt;wiggle sequence&lt;/strong&gt; because the differences (6, -3, 5, -7, 3) are alternately positive and negative.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In contrast, [1, 4, 7, 2, 5] and [1, 7, 4, 5, 5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A &lt;strong&gt;subsequence&lt;/strong&gt; is obtained by deleting some elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [1,7,4,9,2,5]
**Output:** 6
**Explanation:** The entire sequence is a wiggle sequence.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [1,17,5,10,13,15,10,5,16,8]
**Output:** 7
**Explanation:** There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** nums = [1,2,3,4,5,6,7,8,9]
**Output:** 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;With this problem, we have to find the longest wiggle subsequence. Wiggle subsequence means that the difference between successive elements is alternating between positive and negative.&lt;/p&gt;

&lt;p&gt;For solving this problem we will use dynamic programming. We will go through two approaches, one with O(n²) and another one with O(n).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1:&lt;/strong&gt; We will use two arrays up and down. up array refers to the length of the longest wiggle subsequence where the ending element is a rising wiggle. Similarly, the down array refers to the length of the longest wiggle subsequence where the ending element is a falling wiggle.&lt;/p&gt;

&lt;p&gt;We will update the up[i] when we find a rising wiggle at index i. But there is a catch. We have to consider the previous wiggle subsequence which ends with a falling wiggle (because we need to make sure that the subsequence overall is wiggle). We follow the same in the case of down[i].&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Here we are using two loops. To check the longest wiggle subsequence at index i , we check for each element from 0 to i-1.&lt;/p&gt;

&lt;p&gt;Time complexity: O(n²), n is the length of the array&lt;/p&gt;

&lt;p&gt;Space complexity: O(n), n is the length of the array&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 2:&lt;/strong&gt; With this approach, we only use a single loop and two arrays named up and down. Here, we have 3 cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When nums[i]&amp;gt;nums[i-1]:it means it wiggles up. So the element before it must be in down position. Therefore, up[i] = down[i-1]+1 and down[i] will be same as down[i-1].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When nums[i]&amp;lt;nums[i-1]: it means the wiggles down, the element before it must be in up position. Therefore down[i] = 1+up[i-1] and up[i] will be same as up[i-1].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If nums[i]=nums[i-1],then up[i] will be up[i-1] and down[i] will be down[i-1].&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NDSotNOo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AMgzyW08XYtsfyoLk6ku8Qw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NDSotNOo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AMgzyW08XYtsfyoLk6ku8Qw.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Time complexity: O(n), n is the length of the array

&lt;p&gt;Space complexity: O(n), n is the length of the array&lt;/p&gt;

&lt;p&gt;The code can be found here&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Check out my other posts on March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6 — Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://levelup.gitconnected.com/leetcode-706-design-hashmap-march-leetcoding-challenge-2021-fdae1a4adbc"&gt;March LeetCoding Challenge — Day 7 — Design HashMap&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-8-remove-palindromic-subsequences-12b037705722"&gt;March LeetCoding Challenge — Day 8 — Remove Palindromic Subsequences&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-10-integer-to-roman-76caa87a0e07"&gt;March LeetCoding Challenge — Day 10 — Integer to Roman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-48f1fed4d9b9"&gt;March LeetCoding Challenge — Day 12 — Check If a String Contains All Binary Codes of Size K&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-14-swapping-nodes-in-a-linked-list-a540785c816f"&gt;March LeetCoding Challenge — Day 14 — Swapping Nodes in a Linked List&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-15-encode-and-decode-tinyurl-bfeeba44308e"&gt;March LeetCoding Challenge — Day 15 — Encode and Decode TinyURL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 15: Encode and Decode TinyURL</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Wed, 17 Mar 2021 06:15:01 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-15-encode-and-decode-tinyurl-38pc</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-15-encode-and-decode-tinyurl-38pc</guid>
      <description>&lt;p&gt;Today, we will solve the 15th problem of the March LeetCoding Challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;TinyURL is a URL shortening service where you enter a URL such as &lt;a href="https://leetcode.com/problems/design-tinyurl"&gt;https://leetcode.com/problems/design-tinyurl&lt;/a&gt; and it returns a short URL such as &lt;a href="http://tinyurl.com/4e9iAk."&gt;http://tinyurl.com/4e9iAk.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In this problem, we have to design an URL shortening service to encode and decode URLs. Therefore for a given longURL we should be able to get the shortURL with encode method and vice versa in the decode method.&lt;/p&gt;

&lt;p&gt;So we can use the in-built hashcode method, because that will generate a unique value for any given string. We can store the hashcode value in a HashMap and retrieve it in the decode method.&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
The code can be found here&lt;br&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Check out my other posts on March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6 — Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://levelup.gitconnected.com/leetcode-706-design-hashmap-march-leetcoding-challenge-2021-fdae1a4adbc"&gt;March LeetCoding Challenge — Day 7 — Design HashMap&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-8-remove-palindromic-subsequences-12b037705722"&gt;March LeetCoding Challenge — Day 8 — Remove Palindromic Subsequences&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-10-integer-to-roman-76caa87a0e07"&gt;March LeetCoding Challenge — Day 10 — Integer to Roman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-48f1fed4d9b9"&gt;March LeetCoding Challenge — Day 12 — Check If a String Contains All Binary Codes of Size K&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-14-swapping-nodes-in-a-linked-list-a540785c816f"&gt;March LeetCoding Challenge — Day 14-Swapping Nodes in a Linked List&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 14: Swapping Nodes in a Linked List</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Wed, 17 Mar 2021 05:33:35 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-14-swapping-nodes-in-a-linked-list-49e0</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-14-swapping-nodes-in-a-linked-list-49e0</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;You are given the head of a linked list, and an integer k.&lt;/p&gt;

&lt;p&gt;Return &lt;em&gt;the head of the linked list after **swapping **the values of the *kth *node from the beginning and the *kth *node from the end (the list is **1-indexed&lt;/em&gt;&lt;em&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hO9JLrRB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2Aozd8UtUMMkUGyuIn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hO9JLrRB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2Aozd8UtUMMkUGyuIn.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1,2,3,4,5], k = 2
**Output:** [1,4,3,2,5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [7,9,6,6,7,8,3,0,9,5], k = 5
**Output:** [7,9,6,6,8,7,3,0,9,5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1], k = 1
**Output:** [1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 4:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1,2], k = 1
**Output:** [2,1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 5:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** head = [1,2,3], k = 2
**Output:** [1,2,3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The number of nodes in the list is n.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;1 &amp;lt;= k &amp;lt;= n &amp;lt;= 105&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;0 &amp;lt;= Node.val &amp;lt;= 100&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In this problem, we have to swap the k -th node from the beginning with the k -th node from the end. This is a straight forward LinkedList problem.&lt;/p&gt;

&lt;p&gt;Here we are using the 4 nodes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;fast— This is the k -th node from the end&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;slow — This is the k -th node from the start&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;first &amp;amp; second — They are used for swapping (to increase readability also)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Algorithm&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First travel k-1 nodes with the fast node. Save the fast node in the first variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now travel till the end of the list, and do fast = fast.next and slow=slow.next .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When fast.next==null , we store the slow in the second variable. This second variable is the position k nodes before the end.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now swap the values of first and second node.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
The code can be found here&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Check out my other posts on March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6 — Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://levelup.gitconnected.com/leetcode-706-design-hashmap-march-leetcoding-challenge-2021-fdae1a4adbc"&gt;March LeetCoding Challenge — Day 7 — Design HashMap&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-8-remove-palindromic-subsequences-12b037705722"&gt;March LeetCoding Challenge — Day 8 — Remove Palindromic Subsequences&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-10-integer-to-roman-76caa87a0e07"&gt;March LeetCoding Challenge — Day 10 — Integer to Roman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-48f1fed4d9b9"&gt;March LeetCoding Challenge — Day 12 — Check If a String Contains All Binary Codes of Size K&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 7: Design HashMap</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Sat, 13 Mar 2021 10:24:42 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-7-design-hashmap-50o4</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-7-design-hashmap-50o4</guid>
      <description>&lt;p&gt;Today, we will solve the 7th problem of the March LeetCoding Challenge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IwfxEwqu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2ARciEMWkONsv5nV5EA7IXDA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IwfxEwqu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2ARciEMWkONsv5nV5EA7IXDA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Design a HashMap without using any built-in hash table libraries.&lt;/p&gt;

&lt;p&gt;To be specific, your design should include these functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;put(key, value) : Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;get(key): Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;remove(key) : Remove the mapping for the value key if this map contains the mapping for the key.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MyHashMap hashMap = new MyHashMap();
hashMap.put(1, 1);          
hashMap.put(2, 2);         
hashMap.get(1);            // returns 1
hashMap.get(3);            // returns -1 (not found)
hashMap.put(2, 1);          // update the existing value
hashMap.get(2);            // returns 1 
hashMap.remove(2);          // remove the mapping for 2
hashMap.get(2);            // returns -1 (not found)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;All keys and values will be in the range of [0, 1000000].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The number of operations will be in the range of [1, 10000].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Please do not use the built-in HashMap library.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;So in this problem, we are asked to design a HashMap without using any library functions. Here we are going to discuss two approaches to this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1 — Array:&lt;/strong&gt; With this approach, we will initialize an array of a certain size with -1. We will use the given key as the index of the array and will store the given value in the array with that index. We can use this method because the key is always positive. This is a pretty straight forward code. &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Time Complexity:O(1),for get,put,remove methods&lt;/p&gt;

&lt;p&gt;Space Complexity:O(1), the array will occupy 1000001 spaces. &lt;/p&gt;

&lt;p&gt;**Approach 2 — LinkedList: **The previous solution was accepted because the key values are not negative. But in general, that is not the case. So we will try to improve the solution and find the hashed index value and store it in the array. To understand the core concepts behind HashMap and it’s internal implement, check out this amazing youtube playlist. (&lt;a href="https://www.youtube.com/watch?v=wWgIAphfn2U&amp;amp;list=PLqM7alHXFySGwXaessYMemAnITqlZdZVE&amp;amp;ab_channel=GeeksforGeeks"&gt;Youtube&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, by checking the videos we can understand that we may get the same hashed index for different keys(called collision). In order to resolve it, we will use LinkedList.&lt;/p&gt;

&lt;p&gt;Let’s go through the whole algorithm once.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a ListNode class. It is the node for LinkedList. It stores key and value pair.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create an array named nodes of ListNode type. It basically works like the HashMap .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the constructor initialize the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;put method: At first, find the hashed value for the given key . Check whether any other value is stored at that place or not. If not, create a ListNode with (-1,-1) key-value pair and store it in the nodes array. If it is present, then get the reference to the node (prev). If prev.next is null, then create a new ListNode with key-value pair. Else replace the value of the prev.next node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;get method: Repeat the process of finding hashed value and getting reference to the ListNode(prev). If prev.next is null , then return -1 else return prev.next.value .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;remove method: Repeat the process of finding hashed value and getting the reference to the ListNode(prev).To remove that key-value pair from the array, do prev.next=prev.next.next .(Deleting a node from the LinkedList)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The detailed code along with comments is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Time Complexity: O(1) on average, O(n) for worst-case

&lt;p&gt;Space Complexity:O(1), the number of entries is fixed.&lt;/p&gt;

&lt;p&gt;The code can be found here.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Check the previous problems for the March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6— Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computerscience</category>
      <category>algorithms</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Stack Patterns</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Sat, 13 Mar 2021 09:55:02 +0000</pubDate>
      <link>https://dev.to/sksaikia/stack-patterns-2ab3</link>
      <guid>https://dev.to/sksaikia/stack-patterns-2ab3</guid>
      <description>&lt;p&gt;While approaching an algorithmic problem, we should give more attention to the similarities between problems. If we can find these similarities, then solving that kind of problems become very easy. Today we are going to discuss the patterns in the stack.&lt;/p&gt;

&lt;p&gt;With this pattern, we can solve a lot of problems based on the stack. We can even solve the popular &lt;a href="https://www.geeksforgeeks.org/the-stock-span-problem/"&gt;Stock Span&lt;/a&gt; and &lt;a href="https://leetcode.com/problems/largest-rectangle-in-histogram/"&gt;Maximum Area of Histogram&lt;/a&gt; problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Approach&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s go through the &lt;strong&gt;Next Greater Element&lt;/strong&gt; problem. Here we have to find, the next greater element for each number in an array. We will use the stack to store the greater elements. We will traverse the array backwards.&lt;/p&gt;

&lt;p&gt;Algorithm:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Push the last element of the array to the stack&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For all the other elements repeat the following process&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;— Check if the stack is empty,if it is then put -1 at that index. ie. That number does not have any element greater than that to its right side.&lt;br&gt;
 — If the peek of the stack is greater than the current element then the stack peek is the next greater element.&lt;/p&gt;

&lt;p&gt;— If not, keep popping the top of the stack until you find an element greater than the current element&lt;/p&gt;

&lt;p&gt;— If now the stack is empty, place -1 at that index(no greater elements)&lt;/p&gt;

&lt;p&gt;— Else peek of the stack is the greater element&lt;/p&gt;

&lt;p&gt;— push the current element in the stack&lt;/p&gt;

&lt;p&gt;The algorithm can be understood here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LbNng7xY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AZhULRGR14L1vd01OWSQtHg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LbNng7xY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AZhULRGR14L1vd01OWSQtHg.gif" alt="A dry run of the algorithm for the next greater element"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have understood how to solve this problem, you can visualize the other related problems on your own.&lt;/p&gt;

&lt;p&gt;If we follow this approach and with little changes we can solve &lt;strong&gt;Next Smaller Element&lt;/strong&gt;, &lt;strong&gt;Previous Greater Element&lt;/strong&gt; and &lt;strong&gt;Previous Smaller Element&lt;/strong&gt; problem easily.&lt;/p&gt;

&lt;p&gt;All the four problems along with the java code are given below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Greater Element&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Next Smaller Element&lt;/strong&gt;&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Previous Greater Element&lt;/strong&gt;&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Previous Smaller Element&lt;/strong&gt;&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Try these problems by yourself.

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.interviewbit.com/problems/nearest-smaller-element/"&gt;Previous smallest element&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://leetcode.com/problems/132-pattern/"&gt;Previous greater element variation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/find-the-nearest-smaller-numbers-on-left-side-in-an-array/"&gt;Smallest on the left of an array&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/next-greater-element/"&gt;Next greater element&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/next-smaller-element/"&gt;Next smaller element&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/previous-greater-element/"&gt;Previous greater element&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In our future tutorials, we will try to extend this problem and use this pattern to solve more problems. You can try the following problems by yourself.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/the-stock-span-problem/"&gt;Stock Span Problem&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://leetcode.com/problems/largest-rectangle-in-histogram/"&gt;Maximum Area Histogram&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/maximum-size-rectangle-binary-sub-matrix-1s/"&gt;Maximum Area of Histogram in 2D&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The code can be found here&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>March LeetCoding Challenge 2021 — Day 12: Check If a String Contains All Binary Codes of Size K</title>
      <dc:creator>Sourav </dc:creator>
      <pubDate>Sat, 13 Mar 2021 09:53:15 +0000</pubDate>
      <link>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-1056</link>
      <guid>https://dev.to/sksaikia/march-leetcoding-challenge-2021-day-12-check-if-a-string-contains-all-binary-codes-of-size-k-1056</guid>
      <description>&lt;p&gt;Today, we will solve the 12 th problem of the March LeetCoding Challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given a binary string s and an integer k.&lt;/p&gt;

&lt;p&gt;Return &lt;em&gt;True&lt;/em&gt; if every binary code of length k is a substring of s. Otherwise, return &lt;em&gt;False&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** s = "00110110", k = 2
**Output:** true
**Explanation:** The binary codes of length 2 are "00", "01", "10" and "11". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** s = "00110", k = 2
**Output:** true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** s = "0110", k = 1
**Output:** true
**Explanation:** The binary codes of length 1 are "0" and "1", it is clear that both exist as a substring.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 4:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** s = "0110", k = 2
**Output:** false
**Explanation:** The binary code "00" is of length 2 and doesn't exist in the array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 5:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Input:** s = "0000000001011100", k = 4
**Output:** false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In this problem, we are asked to find whether we have all the binary codes of size k in a given string.&lt;/p&gt;

&lt;p&gt;We know that for a given size k, we can have a total of 2^k numbers. We need to check whether all of those 2^k numbers are present in the given string. For that, we can use a HashSet , to store all the values which we have found out. In the end, we can compare the size of HashSet and 2^k , if they are equal then return true else return false.&lt;/p&gt;

&lt;p&gt;The code is given below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Time Complexity: O(n)&lt;/p&gt;

&lt;p&gt;Space Complexity: O(n)&lt;/p&gt;

&lt;p&gt;The code can be found here&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sksaikia"&gt;
        sksaikia
      &lt;/a&gt; / &lt;a href="https://github.com/sksaikia/LeetCode"&gt;
        LeetCode
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
LeetCode&lt;/h1&gt;
&lt;p&gt;I have been solving Leetcode problems for around a year or so. Suddenly I have developed a passion of writing tutorials for these problems. I am starting with Leetcode problem, in future I will try to make tutorials on Spring,Android,Java,Algorithms and many more. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Follow me on medium - &lt;a href="https://sourav-saikia.medium.com" rel="nofollow"&gt;https://sourav-saikia.medium.com&lt;/a&gt; &lt;br&gt;
Follow me on dev.to - &lt;a href="https://dev.to/sksaikia" rel="nofollow"&gt;https://dev.to/sksaikia&lt;/a&gt; &lt;br&gt;
Follow me on twitter - &lt;a href="https://twitter.com/sourav__saikia" rel="nofollow"&gt;https://twitter.com/sourav__saikia&lt;/a&gt; &lt;br&gt;
Connect on Linkedin - &lt;a href="http://www.linkedin.com/in/sourav-kumar-saikia" rel="nofollow"&gt;www.linkedin.com/in/sourav-kumar-saikia&lt;/a&gt; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;The following table contains all the problems with their respective solution tutorials. I will try to add more articles to it soon.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Contains Duplicate&lt;/td&gt;
&lt;td&gt;217&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-217-contains-duplicate-solution-36f48793bce0&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jewels and Stones&lt;/td&gt;
&lt;td&gt;771&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37" rel="nofollow"&gt;https://sourav-saikia.medium.com/leetcode-771-jewels-and-stones-e35a368fc37&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
March LeetCoding Challenge&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem Name&lt;/th&gt;
&lt;th&gt;Problem No&lt;/th&gt;
&lt;th&gt;Article Links&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Distribute Candies&lt;/td&gt;
&lt;td&gt;575&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set Mismatch&lt;/td&gt;
&lt;td&gt;645&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Missing Number&lt;/td&gt;
&lt;td&gt;268&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intersection of Two Linked Lists&lt;/td&gt;
&lt;td&gt;160&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average of Levels in Binary Tree&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;td&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8" rel="nofollow"&gt;https://medium.com/dev-genius/march-leetcoding-challenge-2021-day-5-average-of-levels-in-binary-tree-ac886b2b42e8&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Short Encoding of Words&lt;/td&gt;
&lt;td&gt;820&lt;/td&gt;
&lt;td&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557" rel="nofollow"&gt;https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove Palindromic Subsequences&lt;/td&gt;
&lt;td&gt;1332&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sksaikia/LeetCode"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Check out my other posts on March LeetCoding Challenge 2021.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/dev-genius/march-leetcoding-challenge-2021-problem-1-distribute-candies-f37f66ea7ee9"&gt;March LeetCoding Challenge — Day 1 — Distribute Candies&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-2-set-mismatch-4abd5ee491c9"&gt;March LeetCoding Challenge — Day 2 — Set Mismatch&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-3-missing-number-ae8ee45a58cb"&gt;March LeetCoding Challenge — Day 3 — Missing Number&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-4-intersection-of-two-linked-lists-a775449b5563"&gt;March LeetCoding Challenge — Day 4 — Intersection of Two Linked Lists&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://link.medium.com/sC9L595opeb"&gt;March LeetCoding Challenge — Day 5 — Average of Levels in Binary Tree&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-6-short-encoding-of-words-7fed4bfae557"&gt;March LeetCoding Challenge — Day 6 — Short Encoding of Words&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://sourav-saikia.medium.com/march-leetcoding-challenge-2021-day-8-remove-palindromic-subsequences-12b037705722"&gt;March LeetCoding Challenge — Day 8 — Remove Palindromic Subsequences&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/leetcode-simplified/march-leetcoding-challenge-2021-day-10-integer-to-roman-76caa87a0e07"&gt;March LeetCoding Challenge — Day 10 — Integer to Roman&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>algorithms</category>
      <category>codenewbie</category>
      <category>interview</category>
      <category>leetcode</category>
    </item>
  </channel>
</rss>
