<?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>Forem: Mayur Salokhe</title>
    <description>The latest articles on Forem by Mayur Salokhe (@mayur_salokhe_365ab7a21c6).</description>
    <link>https://forem.com/mayur_salokhe_365ab7a21c6</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%2F3263071%2F73d9d586-f0af-4c8e-8d0e-f766aa530109.jpg</url>
      <title>Forem: Mayur Salokhe</title>
      <link>https://forem.com/mayur_salokhe_365ab7a21c6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mayur_salokhe_365ab7a21c6"/>
    <language>en</language>
    <item>
      <title>Leetcode: Remove Duplicates from Sorted Array</title>
      <dc:creator>Mayur Salokhe</dc:creator>
      <pubDate>Wed, 01 Oct 2025 10:15:45 +0000</pubDate>
      <link>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-remove-duplicates-from-sorted-array-3mnc</link>
      <guid>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-remove-duplicates-from-sorted-array-3mnc</guid>
      <description>&lt;p&gt;Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.&lt;/p&gt;

&lt;p&gt;Consider the number of unique elements of nums to be k, to get accepted, you need to do the following things:&lt;/p&gt;

&lt;p&gt;Change the array nums such that the first k elements of nums contain the unique elements in the order they were present in nums initially. The remaining elements of nums are not important as well as the size of nums.&lt;br&gt;
Return k.&lt;/p&gt;

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

&lt;p&gt;Input: nums = [1,1,2]&lt;br&gt;
Output: 2, nums = [1,2,_]&lt;br&gt;
Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.&lt;br&gt;
It does not matter what you leave beyond the returned k (hence they are underscores).&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: nums = [0,0,1,1,1,2,2,3,3,4]&lt;br&gt;
Output: 5, nums = [0,1,2,3,4,&lt;em&gt;,&lt;/em&gt;,&lt;em&gt;,&lt;/em&gt;,_]&lt;br&gt;
Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.&lt;br&gt;
It does not matter what you leave beyond the returned k (hence they are underscores).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution:
    def removeDuplicates(self, nums: List[int]) -&amp;gt; int:
        n = len(nums)
        res = 1
        for i in range(1,n):
            if nums[i] != nums[i-1]:
                nums[res] = nums[i]
                res += 1
        return res
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>dsa</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Leetcode: Longest Common Prefix</title>
      <dc:creator>Mayur Salokhe</dc:creator>
      <pubDate>Tue, 30 Sep 2025 05:43:23 +0000</pubDate>
      <link>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-longest-common-prefix-12pn</link>
      <guid>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-longest-common-prefix-12pn</guid>
      <description>&lt;p&gt;Write a function to find the longest common prefix string amongst an array of strings.&lt;/p&gt;

&lt;p&gt;If there is no common prefix, return an empty string "".&lt;/p&gt;

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

&lt;p&gt;Input: strs = ["flower","flow","flight"]&lt;br&gt;
Output: "fl"&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: strs = ["dog","racecar","car"]&lt;br&gt;
Output: ""&lt;br&gt;
Explanation: There is no common prefix among the input strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution:
    def longestCommonPrefix(self, strs: List[str]) -&amp;gt; str:
        if not strs:
            return ""

        prefix = strs[0]

        for i in range(len(strs)):
            while not strs[i].startswith(prefix):
                prefix = prefix[:-1]

                if not prefix:
                    return ""
        return prefix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>dsa</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Leetcode : Two Sum</title>
      <dc:creator>Mayur Salokhe</dc:creator>
      <pubDate>Mon, 29 Sep 2025 08:16:59 +0000</pubDate>
      <link>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-two-sum-3bhg</link>
      <guid>https://forem.com/mayur_salokhe_365ab7a21c6/leetcode-two-sum-3bhg</guid>
      <description>&lt;p&gt;Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.&lt;/p&gt;

&lt;p&gt;You may assume that each input would have exactly one solution, and you may not use the same element twice.&lt;/p&gt;

&lt;p&gt;You can return the answer in any order.&lt;/p&gt;

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

&lt;p&gt;Input: nums = [2,7,11,15], target = 9&lt;br&gt;
Output: [0,1]&lt;br&gt;
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: nums = [3,2,4], target = 6&lt;br&gt;
Output: [1,2]&lt;br&gt;
Example 3:&lt;/p&gt;

&lt;p&gt;Input: nums = [3,3], target = 6&lt;br&gt;
Output: [0,1]&lt;/p&gt;

&lt;p&gt;Solution:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution:
    def twoSum(self, nums: List[int], target: int) -&amp;gt; List[int]:
        hashmap = dict()
        for index, num in enumerate(nums):
            diff = target - num
            if diff in hashmap:
                return [index, hashmap[diff]]
            hashmap[num] = index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>leetcode</category>
      <category>dsa</category>
    </item>
    <item>
      <title>First Post on Dev.to</title>
      <dc:creator>Mayur Salokhe</dc:creator>
      <pubDate>Mon, 21 Jul 2025 06:14:00 +0000</pubDate>
      <link>https://forem.com/mayur_salokhe_365ab7a21c6/first-post-on-devto-49lf</link>
      <guid>https://forem.com/mayur_salokhe_365ab7a21c6/first-post-on-devto-49lf</guid>
      <description>&lt;p&gt;Hello Devs!&lt;br&gt;
My name is Mayur, and I'm excited to share my very first post on dev.to! I'm planning to document the new skills I'm learning and the programming challenges I'm solving along the way. As a beginner, I know I might make mistakes, but I’m eager to grow and would love to learn from your feedback and support.&lt;br&gt;
Thanks for joining me on this journey — let’s code and grow together! &lt;/p&gt;

</description>
      <category>programming</category>
      <category>firstpost</category>
      <category>python</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
