<?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: Vaishnvee Shinde </title>
    <description>The latest articles on DEV Community by Vaishnvee Shinde  (@vaishnveeshinde).</description>
    <link>https://dev.to/vaishnveeshinde</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%2F666981%2Fd377c803-b033-4958-bd97-f114da749902.jpg</url>
      <title>DEV Community: Vaishnvee Shinde </title>
      <link>https://dev.to/vaishnveeshinde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vaishnveeshinde"/>
    <language>en</language>
    <item>
      <title>LeetCode - Contains Duplicate</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Fri, 08 Jul 2022 10:51:42 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leetcode-contains-duplicate-12aa</link>
      <guid>https://dev.to/vaishnveeshinde/leetcode-contains-duplicate-12aa</guid>
      <description>&lt;p&gt;Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;code&gt;Input: nums = [1,2,3,1]&lt;br&gt;
Output: true&lt;/code&gt;&lt;/p&gt;

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

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

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

&lt;p&gt;1 &amp;lt;= nums.length &amp;lt;= 105&lt;br&gt;
-109 &amp;lt;= nums[i] &amp;lt;= 109&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&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 {
    public boolean containsDuplicate(int[] no) {
         if(no==null || no.length==0)
        return false;

    HashSet&amp;lt;Integer&amp;gt; set = new HashSet&amp;lt;Integer&amp;gt;();
    for(int i: no){
        if(!set.add(i)){
            return true;
        }
    }

    return false;

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fore more solutions &lt;a href="https://leetcode.com/VaishnveeShinde/"&gt;LeetCode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>leetcode</category>
      <category>containsduplicate</category>
      <category>solution</category>
    </item>
    <item>
      <title>LeetCode - First Bad Version</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Thu, 07 Jul 2022 08:29:55 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leetcode-first-bad-version-2571</link>
      <guid>https://dev.to/vaishnveeshinde/leetcode-first-bad-version-2571</guid>
      <description>&lt;p&gt;You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.&lt;/p&gt;

&lt;p&gt;Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.&lt;/p&gt;

&lt;p&gt;You are given an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;code&gt;Input: n = 5, bad = 4&lt;br&gt;
Output: 4&lt;br&gt;
Explanation:&lt;br&gt;
call isBadVersion(3) -&amp;gt; false&lt;br&gt;
call isBadVersion(5) -&amp;gt; true&lt;br&gt;
call isBadVersion(4) -&amp;gt; true&lt;br&gt;
Then 4 is the first bad version.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
&lt;code&gt;Input: n = 1, bad = 1&lt;br&gt;
Output: 1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Constraints:&lt;br&gt;
1 &amp;lt;= bad &amp;lt;= n &amp;lt;= 231 - 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;public class Solution extends VersionControl {
    public int firstBadVersion(int n) {
        int backword = 1;
        int forword = n;
        while(backword &amp;lt;= forword) {
            int mid = backword + (forword - backword) / 2;
            if(!isBadVersion(mid)) {
                backword = mid + 1;
            }else {
                forword = mid - 1;
            }
        }
        return backword;

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For More Solutions Visit: &lt;a href="https://leetcode.com/VaishnveeShinde/"&gt;Leetcode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>solution</category>
      <category>java</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>Leet Code - Binary Search</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Thu, 07 Jul 2022 08:04:38 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leet-code-binary-search-3fkp</link>
      <guid>https://dev.to/vaishnveeshinde/leet-code-binary-search-3fkp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. &lt;br&gt;
Otherwise, return -1.&lt;br&gt;
You must write an algorithm with O(log n) runtime complexity.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;code&gt;Input: nums = [-1,0,3,5,9,12], target = 9&lt;br&gt;
Output: 4&lt;br&gt;
Explanation: 9 exists in nums and its index is 4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
&lt;code&gt;Input: nums = [-1,0,3,5,9,12], target = 2&lt;br&gt;
Output: -1&lt;br&gt;
Explanation: 2 does not exist in nums so return -1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constraints:&lt;/strong&gt;&lt;br&gt;
1 &amp;lt;= nums.length &amp;lt;= 104&lt;br&gt;
-104 &amp;lt; nums[i], target &amp;lt; 104&lt;br&gt;
All the integers in nums are unique.&lt;br&gt;
nums is sorted in ascending order.&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 {
    public int search(int[] nums, int t) {
        return bsearch(nums,t,0,nums.length-1);
    }
    public int bsearch(int []nums, int t, int l, int high)
    {
        if(high&amp;lt;l)
            return -1;
        int mid = l+(high-l)/2;
        if(nums[mid]==t)
            return mid;
        if(nums[mid]&amp;gt;t)
            return bsearch(nums,t,l,mid-1);
        return bsearch(nums,t,mid+1,high);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For More Solutions Visit: &lt;a href="https://leetcode.com/VaishnveeShinde/"&gt;Leetcode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>leetcode</category>
      <category>solutions</category>
    </item>
    <item>
      <title>Leet Code - Remove Duplicates from Sorted Array</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Sun, 19 Dec 2021 12:10:18 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leet-code-remove-duplicates-from-sorted-array-41bk</link>
      <guid>https://dev.to/vaishnveeshinde/leet-code-remove-duplicates-from-sorted-array-41bk</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.&lt;/p&gt;

&lt;p&gt;Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements.&lt;/p&gt;

&lt;p&gt;Return k after placing the final result in the first k slots of nums.&lt;/p&gt;

&lt;p&gt;Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.`**&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom Judge:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The judge will test your solution with the following code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int[] nums = [...]; // Input array
int[] expectedNums = [...]; // The expected answer with correct length

int k = removeDuplicates(nums); // Calls your implementation

assert k == expectedNums.length;
for (int i = 0; i &amp;lt; k; i++) {
    assert nums[i] == expectedNums[i];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;If all assertions pass, then your solution will be accepted.&lt;/code&gt;&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;/p&gt;

&lt;p&gt;&lt;strong&gt;Java Solution -&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.*;

class Solution {
    public int removeDuplicates(int[] nums) {
        int count = 0;
        for (int i = 0; i &amp;lt; nums.length; i++) {
            if (i &amp;lt; nums.length - 1 &amp;amp;&amp;amp; nums[i] == nums[i + 1]) {
                continue;
            }
            nums[count] = nums[i];
            count++;
        }
        return count;

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>solution</category>
      <category>beginners</category>
      <category>learn</category>
    </item>
    <item>
      <title>Palindrome Number</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Sun, 12 Dec 2021 13:02:41 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/palindrome-number-3hgf</link>
      <guid>https://dev.to/vaishnveeshinde/palindrome-number-3hgf</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Given an integer x, return true if x is palindrome integer.
**
An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Example 1:**

Input: x = 121
Output: true
**Example 2:**

Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
**Example 3:**

Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
**Example 4:**

Input: x = -101
Output: false


**Constraints:**

-231 &amp;lt;= x &amp;lt;= 231 - 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Solution :&lt;br&gt;
Java Code :&lt;/strong&gt;&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 {
    public boolean isPalindrome(int x) {
        if (x &amp;lt; 0) {
            return false;
        }
        int number = x;
        int reverse = 0;
        while (number &amp;gt; 0) {
            reverse = reverse * 10 + number % 10;
            number /= 10;
        }
        return x == reverse;

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Leet Code Soltion - Roman to Integer</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Sun, 12 Dec 2021 12:58:17 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leet-code-soltion-roman-to-integer-4emd</link>
      <guid>https://dev.to/vaishnveeshinde/leet-code-soltion-roman-to-integer-4emd</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol       Value
I             1
V             5
X             10
L             50
C             100
D             500
M             1000**
For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:

I can be placed before V (5) and X (10) to make 4 and 9. 
X can be placed before L (50) and C (100) to make 40 and 90. 
C can be placed before D (500) and M (1000) to make 400 and 900.
Given a roman numeral, convert it to an integer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Example 1:**

Input: s = "III"
Output: 3
**Example 2:**

Input: s = "IV"
Output: 4
**Example 3:**

Input: s = "IX"
Output: 9
**Example 4:**

Input: s = "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.
**Example 5:**

Input: s = "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Constraints:**

1 &amp;lt;= s.length &amp;lt;= 15
s contains only the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M').
It is guaranteed that s is a valid roman numeral in the range [1, 3999].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Solution :&lt;br&gt;
Java Code :&lt;/strong&gt;&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 {
    public int romanToInt(String S) {
        int ans = 0, num = 0;
        for (int i = S.length()-1; i &amp;gt;= 0; i--) {
            switch(S.charAt(i)) {
                case 'I': num = 1; break;
                case 'V': num = 5; break;
                case 'X': num = 10; break;
                case 'L': num = 50; break;
                case 'C': num = 100; break;
                case 'D': num = 500; break;
                case 'M': num = 1000; break;
            }
            if (4 * num &amp;lt; ans) ans -= num;
            else ans += num;
        }
        return ans;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>java</category>
      <category>programming</category>
      <category>free</category>
    </item>
    <item>
      <title>LeetCode - Height Checker Solution</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Fri, 10 Dec 2021 09:13:47 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/leetcode-height-checker-solution-4kc8</link>
      <guid>https://dev.to/vaishnveeshinde/leetcode-height-checker-solution-4kc8</guid>
      <description>&lt;p&gt;`A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the ith student in line.&lt;/p&gt;

&lt;p&gt;You are given an integer array heights representing the current order that the students are standing in. Each heights[i] is the height of the ith student in line (0-indexed).&lt;/p&gt;

&lt;p&gt;Return the number of indices where heights[i] != expected[i].`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Example 1:**

Input: heights = [1,1,4,2,1,3]
Output: 3
Explanation: 
heights:  [1,1,4,2,1,3]
expected: [1,1,1,2,3,4]
Indices 2, 4, and 5 do not match.

**Example 2:**

Input: heights = [5,1,2,3,4]
Output: 5
Explanation:
heights:  [5,1,2,3,4]
expected: [1,2,3,4,5]
All indices do not match.
Example 3:

Input: heights = [1,2,3,4,5]
Output: 0
Explanation:
heights:  [1,2,3,4,5]
expected: [1,2,3,4,5]
All indices match.


**Constraints:**

1 &amp;lt;= heights.length &amp;lt;= 100
1 &amp;lt;= heights[i] &amp;lt;= 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;SOLUTION :&lt;br&gt;
Python Code:&lt;/em&gt;&lt;/strong&gt;&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 heightChecker(self, heights: List[int]) -&amp;gt; int:
        expected = sorted(heights)
        count = 0
        for i, (height, expect) in enumerate(zip(heights, expected)):
            if height != expect:
                count +=1
        return count


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>leetcode</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Python 3.10 Feature</title>
      <dc:creator>Vaishnvee Shinde </dc:creator>
      <pubDate>Fri, 16 Jul 2021 09:41:51 +0000</pubDate>
      <link>https://dev.to/vaishnveeshinde/python-3-10-feature-2ei1</link>
      <guid>https://dev.to/vaishnveeshinde/python-3-10-feature-2ei1</guid>
      <description>&lt;h1&gt;
  
  
  1. Current Problem
&lt;/h1&gt;

&lt;p&gt;With the current Python version, if you want to use type hints for &lt;br&gt;
function that has a parameter which can recive value of different&lt;br&gt;
types, you had to use Union type.&lt;br&gt;&lt;br&gt;
     Something like this:&lt;/p&gt;

&lt;p&gt;def some_funcion(flexible_parameter: Union[int, string]) -&amp;gt; Union[int, string]: return flexible_parameter&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Solution Python 3.10 Feature
&lt;/h1&gt;

&lt;p&gt;It introduces new union operand – |. What this operand says is that certain parameter can be either Type 1 either Type 2.&lt;br&gt;
Now, the previous function can be written like this:&lt;/p&gt;

&lt;p&gt;def some_funcion(flexible_parameter: int | string) -&amp;gt; int |&lt;br&gt;
 string:  return flexible_parameter&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
