<?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: VipulDeshmukh95</title>
    <description>The latest articles on DEV Community by VipulDeshmukh95 (@vipuldeshmukh95).</description>
    <link>https://dev.to/vipuldeshmukh95</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%2F899735%2F49b69ed6-f81d-44cb-a8d0-95b29708000d.png</url>
      <title>DEV Community: VipulDeshmukh95</title>
      <link>https://dev.to/vipuldeshmukh95</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vipuldeshmukh95"/>
    <language>en</language>
    <item>
      <title>Second Largest Num in Array</title>
      <dc:creator>VipulDeshmukh95</dc:creator>
      <pubDate>Tue, 27 Dec 2022 16:39:10 +0000</pubDate>
      <link>https://dev.to/vipuldeshmukh95/second-largest-num-in-array-5a82</link>
      <guid>https://dev.to/vipuldeshmukh95/second-largest-num-in-array-5a82</guid>
      <description>&lt;p&gt;Approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First got the max num from array.&lt;/li&gt;
&lt;li&gt;Using the above max num, got the second max num&lt;/li&gt;
&lt;li&gt;If the 2nd Largest num is present, I have returned it.&lt;/li&gt;
&lt;li&gt;If such 2nd largest num is absent, I have returned -1.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int Solution::solve(vector&amp;lt;int&amp;gt; &amp;amp;A) {
    int max_num = INT_MIN;
    int max_sec = INT_MIN;
    int n = A.size();


    for(int i = 0; i &amp;lt; n; i++)
    {
        max_num = max(max_num, A[i]);
    }

    for(int i = 0; i &amp;lt; n; i++) 
    {
        if(A[i] != max_num)
        {
          max_sec = max(max_sec, A[i]);
        }
    }

    if(max_sec != INT_MIN)
    {
        return max_sec;
    }
    else{
    return -1;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Arrays</title>
      <dc:creator>VipulDeshmukh95</dc:creator>
      <pubDate>Sun, 07 Aug 2022 20:11:23 +0000</pubDate>
      <link>https://dev.to/vipuldeshmukh95/arrays-c25</link>
      <guid>https://dev.to/vipuldeshmukh95/arrays-c25</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;Simple code to show how the Accessing and Modifying of array elements is done:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;// AccessingAndModifyingArrayElements.cpp : This file contains the 'main' function. Program execution begins and ends there.&lt;br&gt;
//&lt;/p&gt;

&lt;h1&gt;
  
  
  include "pch.h"
&lt;/h1&gt;

&lt;h1&gt;
  
  
  include 
&lt;/h1&gt;

&lt;p&gt;using namespace std;&lt;/p&gt;

&lt;p&gt;int main()&lt;br&gt;
{&lt;br&gt;
    //std::cout &amp;lt;&amp;lt; "Hello World!\n";&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//1. Accessing array elements
cout &amp;lt;&amp;lt; "1. Accessing array elements : " &amp;lt;&amp;lt; endl;
int arr[]{ 100, 20, 30, 50, 60 };

cout &amp;lt;&amp;lt; "Array element 1: " &amp;lt;&amp;lt; arr[0] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 2: " &amp;lt;&amp;lt; arr[1] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 3: " &amp;lt;&amp;lt; arr[2] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 4: " &amp;lt;&amp;lt; arr[3] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 5: " &amp;lt;&amp;lt; arr[4] &amp;lt;&amp;lt; endl;

//2. Arrays are not check for out of bounds :
// Most probably code will crash in such situations.
//cout &amp;lt;&amp;lt; "enter any number for arr[5] : " &amp;lt;&amp;lt; endl;

//cin &amp;gt;&amp;gt; arr[5];

//3. Initializing array:
cout &amp;lt;&amp;lt; "\n";
cout &amp;lt;&amp;lt; "===============" &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "\n";
//int arr1[5];
//int arr2[5]{};
int arr3[5]{100, 90};

cout &amp;lt;&amp;lt; "Array element 1: " &amp;lt;&amp;lt; arr3[0] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 2: " &amp;lt;&amp;lt; arr3[1] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 3: " &amp;lt;&amp;lt; arr3[2] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 4: " &amp;lt;&amp;lt; arr3[3] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; "Array element 5: " &amp;lt;&amp;lt; arr3[4] &amp;lt;&amp;lt; endl;

//4. Modifying array elements
cout &amp;lt;&amp;lt; "Enter 5 nums for arr3 : ";
cin &amp;gt;&amp;gt; arr3[0];
cin &amp;gt;&amp;gt; arr3[1];
cin &amp;gt;&amp;gt; arr3[2];
cin &amp;gt;&amp;gt; arr3[3];
cin &amp;gt;&amp;gt; arr3[4];

cout &amp;lt;&amp;lt; "MOdified array : " &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; arr3[0] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; arr3[1] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; arr3[2] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; arr3[3] &amp;lt;&amp;lt; endl;
cout &amp;lt;&amp;lt; arr3[4] &amp;lt;&amp;lt; endl;

cout &amp;lt;&amp;lt; "the value of array name is : " &amp;lt;&amp;lt; arr3 &amp;lt;&amp;lt; endl;  // this shows the address value of 1st element of array.

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

&lt;/div&gt;

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

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5LMHju5W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i30ymniolrajqsvqymjt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5LMHju5W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i30ymniolrajqsvqymjt.PNG" alt="Image description" width="880" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arrays</category>
      <category>cpp</category>
    </item>
    <item>
      <title>My first LeetCode(which I failed, although I had a correct logic in my mind)</title>
      <dc:creator>VipulDeshmukh95</dc:creator>
      <pubDate>Thu, 28 Jul 2022 20:16:00 +0000</pubDate>
      <link>https://dev.to/vipuldeshmukh95/my-first-leetcodewhich-i-failed-although-had-a-correct-logic-in-my-mind-4688</link>
      <guid>https://dev.to/vipuldeshmukh95/my-first-leetcodewhich-i-failed-although-had-a-correct-logic-in-my-mind-4688</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;LeetCode#242 Anagram Code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;class Solution {&lt;br&gt;
public:&lt;br&gt;
    bool isAnagram(string s, string t) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   int n1 = s.length();
   int n2 = t.length();

    if((n1  &amp;gt; 50000) || (n2 &amp;gt; 50000))
    {
        return false;

    }
    if(n1 != n2)
    {
         return false;
    }

    //sorting both strings
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for(int i = 0; i &amp;lt;= n2; i++)
    {
         if(s[i] != s[i])
             return false;
    }

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

&lt;/div&gt;

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

</description>
      <category>cpp</category>
    </item>
  </channel>
</rss>
