<?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: Ruparani777</title>
    <description>The latest articles on DEV Community by Ruparani777 (@ruparani777).</description>
    <link>https://dev.to/ruparani777</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%2F834844%2F899a379f-fab6-4f6d-983d-b177f36889ef.png</url>
      <title>DEV Community: Ruparani777</title>
      <link>https://dev.to/ruparani777</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ruparani777"/>
    <language>en</language>
    <item>
      <title>MYSQL FOR BEGINNERS</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Fri, 22 Sep 2023 04:37:50 +0000</pubDate>
      <link>https://dev.to/ruparani777/mysql-for-beginners-2il0</link>
      <guid>https://dev.to/ruparani777/mysql-for-beginners-2il0</guid>
      <description>&lt;p&gt;MySQL, one of the most popular open-source relational database management systems, is an excellent place to start. In this beginner's guide, we'll take you through the fundamental steps of learning MySQL from scratch.&lt;/p&gt;

&lt;p&gt;What is MySQL?&lt;/p&gt;

&lt;p&gt;MySQL is a powerful and flexible database management system that's widely used for web development, data storage, and more. It's known for its speed, reliability, and ease of use, making it an ideal choice for beginners and experienced developers alike.&lt;/p&gt;

&lt;p&gt;Getting Started&lt;/p&gt;

&lt;p&gt;Installation: Start by installing MySQL on your computer. MySQL offers various editions, including a free and open-source Community Edition, which is perfect for beginners. You can download it from the &lt;br&gt;
&lt;a href="https://dev.mysql.com/downloads/installer/"&gt;https://dev.mysql.com/downloads/installer/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basic Concepts: Familiarize yourself with the basic concepts of databases, tables, records, and fields. Understand how data is organized and stored in a relational database.&lt;/p&gt;

&lt;p&gt;Creating Your First Database&lt;/p&gt;

&lt;p&gt;MySQL Client: MySQL provides a command-line client and graphical user interface tools. Begin with the command-line client to understand the core concepts. You can access it by running mysql from your terminal or command prompt.&lt;/p&gt;

&lt;p&gt;Creating a Database: Use the CREATE DATABASE statement to create your first database. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE mydatabase;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Working with Tables&lt;/p&gt;

&lt;p&gt;Creating Tables: Databases consist of tables that hold your data. Learn how to create tables with the CREATE TABLE statement. Define the table structure, specifying columns and their data types.&lt;/p&gt;

&lt;p&gt;Inserting Data: Use the INSERT INTO statement to add data to your tables. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO mytable (column1, column2) VALUES ('value1', 'value2');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retrieving Data: Learn the basics of querying data with the SELECT statement. You can filter, sort, and retrieve specific information from your tables.&lt;/p&gt;

&lt;p&gt;Manipulating Data&lt;/p&gt;

&lt;p&gt;Updating Data: Use the UPDATE statement to modify existing data in your tables.&lt;/p&gt;

&lt;p&gt;Deleting Data: The DELETE statement allows you to remove records from a table.&lt;/p&gt;

&lt;p&gt;Advanced Topics&lt;/p&gt;

&lt;p&gt;Indexes: Understand how indexes improve query performance by allowing MySQL to locate data faster.&lt;/p&gt;

&lt;p&gt;Relationships: Explore the concept of relational databases and how to establish relationships between tables.&lt;/p&gt;

&lt;p&gt;Normalization: Learn about database normalization, a process that optimizes data storage and reduces redundancy.&lt;/p&gt;

&lt;p&gt;User Management: Secure your MySQL installation by creating and managing user accounts with appropriate privileges.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>mysql</category>
      <category>webdev</category>
    </item>
    <item>
      <title>XML</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Thu, 10 Aug 2023 13:06:06 +0000</pubDate>
      <link>https://dev.to/ruparani777/xml-h7k</link>
      <guid>https://dev.to/ruparani777/xml-h7k</guid>
      <description>&lt;p&gt;XML is a markup language that's used to structure and store data in a human-readable format. It's commonly used for data interchange between different systems, web applications, and more. Here's a simple breakdown:&lt;/p&gt;

&lt;p&gt;Markup Language: XML uses tags to mark up data. Tags are enclosed in angle brackets, like . They define the structure and meaning of the data.&lt;/p&gt;

&lt;p&gt;Elements: An XML document is made up of elements. An element consists of an opening tag, content, and a closing tag. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;book&amp;gt;
    &amp;lt;title&amp;gt;Harry Potter&amp;lt;/title&amp;gt;
    &amp;lt;author&amp;gt;J.K. Rowling&amp;lt;/author&amp;gt;
&amp;lt;/book&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example,  is the opening tag,  is the closing tag, and everything in between is the content.&lt;/p&gt;

&lt;p&gt;Attributes: Elements can have attributes, which provide additional information about the element. Attributes are placed inside the opening tag. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;book language="english"&amp;gt;
    &amp;lt;title&amp;gt;Harry Potter&amp;lt;/title&amp;gt;
    &amp;lt;author&amp;gt;J.K. Rowling&amp;lt;/author&amp;gt;
&amp;lt;/book&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, language is an attribute with the value "english".&lt;/p&gt;

&lt;p&gt;Nesting: You can nest elements within other elements to create a hierarchical structure. For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;library&amp;gt;
    &amp;lt;book&amp;gt;
        &amp;lt;title&amp;gt;Harry Potter&amp;lt;/title&amp;gt;
        &amp;lt;author&amp;gt;J.K. Rowling&amp;lt;/author&amp;gt;
    &amp;lt;/book&amp;gt;
    &amp;lt;book&amp;gt;
        &amp;lt;title&amp;gt;The Hobbit&amp;lt;/title&amp;gt;
        &amp;lt;author&amp;gt;J.R.R. Tolkien&amp;lt;/author&amp;gt;
    &amp;lt;/book&amp;gt;
&amp;lt;/library&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here,  contains two  elements.&lt;/p&gt;

&lt;p&gt;Self-Closing Tags: Some elements don't have content and are self-contained. You can use self-closing tags for these elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;image src="picture.jpg" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Comments: You can add comments to your XML code using &amp;lt;!-- for the opening of the comment and --&amp;gt; for the closing:&lt;/p&gt;

&lt;p&gt;Remember, XML is primarily used for structuring and describing data, so it doesn't have built-in interactivity like programming languages. It's important to follow the rules of XML, such as properly nesting elements and using balanced opening and closing tags.&lt;/p&gt;

&lt;p&gt;XML is widely used, especially in areas like web services, configuration files, and data exchange between different applications. It's a foundational concept for understanding more advanced technologies like JSON and HTML.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>VALID ANAGRAM LEETCODE SOLUTION C++ WITH OPTIMISED SOLUTION</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Mon, 10 Jul 2023 07:20:35 +0000</pubDate>
      <link>https://dev.to/ruparani777/valid-anagram-leetcode-solution-c-with-optimised-solution-35i4</link>
      <guid>https://dev.to/ruparani777/valid-anagram-leetcode-solution-c-with-optimised-solution-35i4</guid>
      <description>&lt;p&gt;Given two strings s and t, return true if t is an anagram of s, and false otherwise.&lt;/p&gt;

&lt;p&gt;An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.&lt;/p&gt;

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

&lt;p&gt;Input: s = "anagram", t = "nagaram"&lt;br&gt;
Output: true&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: s = "rat", t = "car"&lt;br&gt;
Output: false&lt;/p&gt;

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

&lt;p&gt;1 &amp;lt;= s.length, t.length &amp;lt;= 5 * 104&lt;br&gt;
s and t consist of lowercase English letters.&lt;/p&gt;

&lt;p&gt;SOLUTION C++ :TC (OLOGN)&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:
    bool isAnagram(string s, string t) {
       int n1=s.length();
       int n2=t.length();
       if(n1!=n2) return false;
       sort(s.begin(),s.end());
       sort(t.begin(),t.end());

           if(s!=t)
               return false;

           return true;

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

&lt;/div&gt;



&lt;p&gt;SOLUTION C++:TC O(N)&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:
    bool isAnagram(string s, string t) {
  //      Time Complexity : O(N)
/* Space Complexity : O(1), Constant space. As we are using26size-frequency array to store the frequency of every character which is constant.*/
        if(s.length()!=t.length()){
            return false;
        }
        int arr[26]={0};

        for(int i=0;i&amp;lt;s.length();i++){  //solved using string and hashtable
            arr[s[i]-'a']++;
            arr[t[i]-'a']--;
        }
        for(int i=0;i&amp;lt;26;i++){
            if(arr[i]!=0){
                return false;
            }
        }
        return true;

    }

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

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>REVERSE A STRING LEETCODE SOLUTION 2 c++</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Mon, 10 Jul 2023 05:17:06 +0000</pubDate>
      <link>https://dev.to/ruparani777/reverse-a-string-leetcode-solution-2-c-2bh5</link>
      <guid>https://dev.to/ruparani777/reverse-a-string-leetcode-solution-2-c-2bh5</guid>
      <description>&lt;p&gt;DESCRIPTION:&lt;br&gt;
Write a function that reverses a string. The input string is given as an array of characters s.&lt;/p&gt;

&lt;p&gt;You must do this by modifying the input array in-place with O(1) extra memory.&lt;/p&gt;

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

&lt;p&gt;Input: s = ["h","e","l","l","o"]&lt;br&gt;
Output: ["o","l","l","e","h"]&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: s = ["H","a","n","n","a","h"]&lt;br&gt;
Output: ["h","a","n","n","a","H"]&lt;/p&gt;

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

&lt;p&gt;1 &amp;lt;= s.length &amp;lt;= 105&lt;br&gt;
s[i] is a printable ascii character.&lt;/p&gt;

&lt;p&gt;1.STRING GIVEN EG: RUPA&lt;br&gt;
2.CHAR ARRAY GIVEN EG: ["R","U","P","A"]&lt;/p&gt;

&lt;p&gt;1.STRING GIVEN EG: RUPA&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;bits/stdc++.h&amp;gt; 
using namespace std; 

void reverse(string s){ 
   for(int i=s.length()-1; i&amp;gt;=0; i--) 
      cout&amp;lt;&amp;lt;s[i];  
} 

int main(){ 
    string s = "Rupa"; 
    reverse(s); 
    return 0; 
}

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

&lt;/div&gt;



&lt;p&gt;2.2.CHAR ARRAY GIVEN EG: &lt;a href="https://dev.toLEETCODE%20SOLUTION"&gt;"R","U","P","A"&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SOLUTION C++;&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:
    void reverseString(vector&amp;lt;char&amp;gt;&amp;amp; s) {
        int n=s.size();
        int l=0;
        int r=n-1;
        while(l&amp;lt;=r){
            swap(s[l],s[r]);
            l++;
            r--;
        }


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

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>REVERSE INTEGER -LEETCODE SOLUTION C++</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Mon, 10 Jul 2023 04:44:32 +0000</pubDate>
      <link>https://dev.to/ruparani777/reverse-integer-leetcode-solution-c-2g4d</link>
      <guid>https://dev.to/ruparani777/reverse-integer-leetcode-solution-c-2g4d</guid>
      <description>&lt;p&gt;Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.&lt;/p&gt;

&lt;p&gt;Assume the environment does not allow you to store 64-bit integers (signed or unsigned).&lt;/p&gt;

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

&lt;p&gt;Input: x = 123&lt;br&gt;
Output: 321&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: x = -123&lt;br&gt;
Output: -321&lt;br&gt;
Example 3:&lt;/p&gt;

&lt;p&gt;Input: x = 120&lt;br&gt;
Output: 21&lt;/p&gt;

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

&lt;p&gt;-231 &amp;lt;= x &amp;lt;= 231 - 1&lt;/p&gt;

&lt;p&gt;SOLUTION C++&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 reverse(int x) {
        int num = x;
        long int rev = 0;
        while(num != 0){
            int digit = num%10;
            rev = 10*rev + digit;
            if(rev &amp;gt; INT_MAX)return 0;//1
            if(rev &amp;lt; INT_MIN)return 0;//2
            num/=10;
        }
        return (int)rev;
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;LINE 1 AND 2 used due to if their is any negative values exist &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>MOVE ZEROS IN AN ARRAY LEETCODE SOLUTION C++ |ARSH GOYAL DSA SHEET</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Sat, 08 Jul 2023 05:45:01 +0000</pubDate>
      <link>https://dev.to/ruparani777/move-zeros-in-an-array-leetcode-solution-c-arsh-goyal-dsa-sheet-3p8d</link>
      <guid>https://dev.to/ruparani777/move-zeros-in-an-array-leetcode-solution-c-arsh-goyal-dsa-sheet-3p8d</guid>
      <description>&lt;p&gt;DESCRIPTION:&lt;br&gt;
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.&lt;/p&gt;

&lt;p&gt;Note that you must do this in-place without making a copy of the array.&lt;/p&gt;

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

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

&lt;p&gt;Input: nums = [0]&lt;br&gt;
Output: [0]&lt;/p&gt;

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

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

&lt;p&gt;Follow up: Could you minimize the total number of operations done?&lt;/p&gt;

&lt;p&gt;1.NAIVE : PICK NON ZERO ELEMENT PLACE IN TEMP ARRAY  ,REST 0'S&lt;br&gt;
2.OPTIMAL: PICK ZERO INCREMENT ELSE SWAP ZERO ELEMNET WITH NON ZERO ELEMENT&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&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:
    void moveZeroes(vector&amp;lt;int&amp;gt;&amp;amp; nums) {
        int n = nums.size();
        int i = 0, j = 0;
        while(j&amp;lt;n)
        {
            if(nums[j]==0) j++;//if u found zero ,increment
            else{
                swap(nums[i], nums[j]); //if u found non zero swap it with zero 
                i++;
                j++;
            }
        }
    }
};

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

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>TWO SUM LEETCODE SOLUTION C++|ARSH GOYAL DSA SHEET</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Sat, 08 Jul 2023 05:05:52 +0000</pubDate>
      <link>https://dev.to/ruparani777/two-sum-leetcode-solution-carsh-goyal-dsa-sheet-1p74</link>
      <guid>https://dev.to/ruparani777/two-sum-leetcode-solution-carsh-goyal-dsa-sheet-1p74</guid>
      <description>&lt;p&gt;DESCRIPTION:&lt;br&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;Constraints:&lt;/p&gt;

&lt;p&gt;2 &amp;lt;= nums.length &amp;lt;= 104&lt;br&gt;
-109 &amp;lt;= nums[i] &amp;lt;= 109&lt;br&gt;
-109 &amp;lt;= target &amp;lt;= 109&lt;br&gt;
Only one valid answer exists.&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&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:
    vector&amp;lt;int&amp;gt; twoSum(vector&amp;lt;int&amp;gt;&amp;amp; nums, int target) {
        vector&amp;lt;int&amp;gt; ans;
        map&amp;lt;int, int&amp;gt; mpp;
        for (int i = 0; i &amp;lt; nums.size(); i++) {
            int t = target - nums[i];
            if (mpp.find(t) != mpp.end()) {
                ans.push_back(mpp[t]);
                ans.push_back(i);
                break;
            }
            mpp[nums[i]] = i;
        }
        return ans;
    }
};



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

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>welcome</category>
    </item>
    <item>
      <title>SORT THE COLORS LEETCODE SOLUTION C++ OR SORT 0 1 2 IN AN ARRAY</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Fri, 07 Jul 2023 10:02:24 +0000</pubDate>
      <link>https://dev.to/ruparani777/sort-the-colors-leetcode-solution-c-or-sort-0-1-2-in-an-array-4dm</link>
      <guid>https://dev.to/ruparani777/sort-the-colors-leetcode-solution-c-or-sort-0-1-2-in-an-array-4dm</guid>
      <description>&lt;p&gt;Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.&lt;/p&gt;

&lt;p&gt;We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.&lt;/p&gt;

&lt;p&gt;You must solve this problem without using the library's sort function.&lt;/p&gt;

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

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

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

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

&lt;p&gt;n == nums.length&lt;br&gt;
1 &amp;lt;= n &amp;lt;= 300&lt;br&gt;
nums[i] is either 0, 1, or 2.&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&lt;/p&gt;

&lt;p&gt;`class Solution {&lt;br&gt;
public:&lt;br&gt;
    void sortColors(vector&amp;amp; nums) {&lt;br&gt;
    int n=nums.size();&lt;br&gt;
    int low = 0, mid = 0, high = n - 1; // 3 pointers&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (mid &amp;lt;= high) {
    if (nums[mid] == 0) {
        swap(nums[low], nums[mid]);
        low++;
        mid++;
    }
    else if (nums[mid] == 1) {
        mid++;
    }
    else {
        swap(nums[mid], nums[high]);
        high--;
    }
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>STOCK BUY AND SELL 1 AND 11 leetcode solution C++</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Fri, 07 Jul 2023 09:41:10 +0000</pubDate>
      <link>https://dev.to/ruparani777/stock-buy-and-sell-1-and-11-leetcode-solution-c-5f03</link>
      <guid>https://dev.to/ruparani777/stock-buy-and-sell-1-and-11-leetcode-solution-c-5f03</guid>
      <description>&lt;p&gt;STOCK BUY AND SELL I:&lt;br&gt;
ou are given an array prices where prices[i] is the price of a given stock on the ith day.&lt;/p&gt;

&lt;p&gt;You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.&lt;/p&gt;

&lt;p&gt;Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.&lt;/p&gt;

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

&lt;p&gt;Input: prices = [7,1,5,3,6,4]&lt;br&gt;
Output: 5&lt;br&gt;
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.&lt;br&gt;
Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell.&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: prices = [7,6,4,3,1]&lt;br&gt;
Output: 0&lt;br&gt;
Explanation: In this case, no transactions are done and the max profit = 0.&lt;/p&gt;

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

&lt;p&gt;1 &amp;lt;= prices.length &amp;lt;= 105&lt;br&gt;
0 &amp;lt;= prices[i] &amp;lt;= 104&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&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 maxProfit(vector&amp;lt;int&amp;gt;&amp;amp; prices) {
        int n=prices.size();
        int maxpro=0;
        int minprice=INT_MAX;
        for(int i=0;i&amp;lt;n;i++){
            minprice=min(minprice,prices[i]);
            maxpro=max(maxpro,prices[i]-minprice);
        }
        return maxpro;
    }
};


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

&lt;/div&gt;



&lt;p&gt;STOCK BUY AND SELL II :&lt;br&gt;
You are given an integer array prices where prices[i] is the price of a given stock on the ith day.&lt;/p&gt;

&lt;p&gt;On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day.&lt;/p&gt;

&lt;p&gt;Find and return the maximum profit you can achieve.&lt;/p&gt;

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

&lt;p&gt;Input: prices = [7,1,5,3,6,4]&lt;br&gt;
Output: 7&lt;br&gt;
Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit = 5-1 = 4.&lt;br&gt;
Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 = 3.&lt;br&gt;
Total profit is 4 + 3 = 7.&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: prices = [1,2,3,4,5]&lt;br&gt;
Output: 4&lt;br&gt;
Explanation: Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit = 5-1 = 4.&lt;br&gt;
Total profit is 4.&lt;br&gt;
Example 3:&lt;/p&gt;

&lt;p&gt;Input: prices = [7,6,4,3,1]&lt;br&gt;
Output: 0&lt;br&gt;
Explanation: There is no way to make a positive profit, so we never buy the stock to achieve the maximum profit of 0.&lt;/p&gt;

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

&lt;p&gt;1 &amp;lt;= prices.length &amp;lt;= 3 * 104&lt;br&gt;
0 &amp;lt;= prices[i] &amp;lt;= 104&lt;/p&gt;

&lt;p&gt;SOLUTION C++:&lt;/p&gt;

&lt;p&gt;class Solution {&lt;br&gt;
public:&lt;br&gt;
    int maxProfit(vector&amp;amp; prices) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    int n=prices.size();
    int maxpro = 0;
    for (int i = 1; i &amp;lt; n; i++) {
        if (prices[i] &amp;gt; prices[i - 1])
            maxpro += prices[i] - prices[i - 1];
    }
    return maxpro;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

</description>
    </item>
    <item>
      <title>FIND THE DUPLICATE NUMBER LEETCODE SOLUTION C++</title>
      <dc:creator>Ruparani777</dc:creator>
      <pubDate>Fri, 07 Jul 2023 09:04:30 +0000</pubDate>
      <link>https://dev.to/ruparani777/find-the-duplicate-number-leetcode-solution-c-1cen</link>
      <guid>https://dev.to/ruparani777/find-the-duplicate-number-leetcode-solution-c-1cen</guid>
      <description>&lt;p&gt;Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.&lt;/p&gt;

&lt;p&gt;There is only one repeated number in nums, return this repeated number.&lt;/p&gt;

&lt;p&gt;You must solve the problem without modifying the array nums and uses only constant extra space.&lt;/p&gt;

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

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

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

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

&lt;p&gt;1 &amp;lt;= n &amp;lt;= 105&lt;br&gt;
nums.length == n + 1&lt;br&gt;
1 &amp;lt;= nums[i] &amp;lt;= n&lt;br&gt;
All the integers in nums appear only once except for precisely one integer which appears two or more times.&lt;/p&gt;

&lt;p&gt;C++ 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 findDuplicate(vector&amp;lt;int&amp;gt;&amp;amp; nums)//LINKED LIST CYCLE METHOD 
     {
        int slow = nums[0];
        int fast = nums[0];
        do {
            slow = nums[slow];
            fast = nums[nums[fast]];
        } while (slow != fast);
        // Find the "entrance" to the cycle.
        slow = nums[0];
        while (slow != fast) // WHENEVER  2ND TYM FAST AND SLOW POINTER MEETS IT GIVES DUPLICATE NUMBER  (EITHER THE FAST OR SLOW )
        {
            slow = nums[slow];
            fast = nums[fast];
        }
        return slow;
    }

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

&lt;/div&gt;



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