<?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: Saloni Gupta</title>
    <description>The latest articles on DEV Community by Saloni Gupta (@salonix__).</description>
    <link>https://dev.to/salonix__</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%2F454052%2F2d783a29-e6e9-4a5f-830f-cd7aeb667907.png</url>
      <title>DEV Community: Saloni Gupta</title>
      <link>https://dev.to/salonix__</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salonix__"/>
    <language>en</language>
    <item>
      <title>All About React Native</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Fri, 02 Jul 2021 17:48:25 +0000</pubDate>
      <link>https://dev.to/salonix__/all-about-react-native-4jbl</link>
      <guid>https://dev.to/salonix__/all-about-react-native-4jbl</guid>
      <description>&lt;p&gt;Are you planning to create a react-native app? You’ll probably get a lot of inquiries like, “Should I use boilerplate?” What exactly is a boilerplate? Is it better to use Expo or not?&lt;/p&gt;

&lt;p&gt;Let me start by saying that I am absolutely new to this tech stack. I have been developing apps in Dart for a long time and decided to branch out because JavaScript is getting increasingly popular.&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;React Native:&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;React Native (also known as RN) is a popular &lt;b&gt;JavaScript-based mobile app framework&lt;/b&gt; created by Facebook that allows you to build natively rendered mobile apps for iOS and Android. The framework lets you create an application for various platforms by using the same codebase.&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Boilerplates:&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;Boilerplates are a type of template that makes building an app from scratch easier. I looked into boilerplates further and learned about a handful of them. You can have a look at some popular boilerplates &lt;a href="https://blog.logrocket.com/top-react-native-boilerplates-for-2021/"&gt;here&lt;/a&gt; and determine whether or not to employ them.&lt;/p&gt;

&lt;p&gt;Ignite by Infinite Red is the most popular one, it has over 12k stars on Github. Let’s dive deep into it. It is a cutting edge react native project boilerplate, that includes a CLI, component/model generators and many more.&lt;br&gt;
This Typescript-ready project uses MobX for state management, React-navigation for routing and navigation, Apisauce for talking with REST servers, and the Jest framework for testing.&lt;br&gt;
If you are a complete beginner, then I would suggest you go through this.&lt;/p&gt;

&lt;p&gt;There are basically two methods to create the react-native application:&lt;br&gt;
1.Expo&lt;br&gt;
2.React-native CLI&lt;br&gt;
We will go through both of them one by one&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Expo&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;Expo is a framework that is used to build React Native apps. It is basically a bundle with tools and services built for React Native, that will help you get started with building React Native apps with ease.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Advantages:&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up a project is easy and can be done in minutes&lt;/li&gt;
&lt;li&gt;Anyone can open the project while you’re working on it&lt;/li&gt;
&lt;li&gt;Sharing the app is easy (via QR-code or link), you don’t have to send the whole .apk or .ipa file&lt;/li&gt;
&lt;li&gt;No build necessary to run the app&lt;/li&gt;
&lt;li&gt;Integrates some basic libraries in a standard project (Push Notifications, Asset Manager, etc.)&lt;/li&gt;
&lt;li&gt;You can eject it to ExpoKit and integrate native code continuing using some of the Expo features, but not all of them&lt;/li&gt;
&lt;li&gt;Expo can build .apk and .ipa files (distribution to stores possible with Expo)&lt;/li&gt;
&lt;li&gt;And the most important one, at least for me, You don’t have to own a Macbook for developing iOS applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Disadvantages:&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can’t add native modules (probably a game-changer for some)&lt;/li&gt;
&lt;li&gt;You can’t use libraries that use native code in Objective-C/Java&lt;/li&gt;
&lt;li&gt;The standard Hello World app is about 25MB big (because of the integrated libraries)&lt;/li&gt;
&lt;li&gt;If you want to use: FaceDetector, ARKit, or Payments you need to eject it to ExpoKit&lt;/li&gt;
&lt;li&gt;Ejecting it to ExpoKit has a trade-off of features of Expo, e.g. you cannot share via QR code&lt;/li&gt;
&lt;li&gt;When ejecting to ExpoKit you are limited to the react-native version that is supported by ExpoKit then&lt;/li&gt;
&lt;li&gt;Debugging in ExpoKit (with native modules) is a lot more complicated since it mixes two languages and different libraries (no official Expo support anymore)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;&lt;b&gt;React-native CLI:&lt;/b&gt;&lt;/h2&gt;

&lt;p&gt;It generates a plain react-native project for you with separate native projects for iOS and Android platforms. You just have to type the “react-native init” command.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Advantages:&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can add native modules written in Java/Objective-C (probably the only but the strongest one)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Disadvantages:&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Needs Android Studio and XCode to run the projects&lt;/li&gt;
&lt;li&gt;You can’t develop for iOS without having a mac&lt;/li&gt;
&lt;li&gt;The device has to be connected via USB to use for testing&lt;/li&gt;
&lt;li&gt;Fonts need to be imported manually in XCode&lt;/li&gt;
&lt;li&gt;If you want to share the app you need to send the whole .apk / .ipa file&lt;/li&gt;
&lt;li&gt;Does not provide JS APIs out of the box, e.g. Push-Notifications, Asset Manager, they need to be manually installed and linked with npm for example&lt;/li&gt;
&lt;li&gt;Setting up a working project properly (including device configuration) is rather complicated and can take time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is all that you need to know before switching to react-native. I struggled a lot in these things, so thought to share.&lt;/p&gt;

&lt;p&gt;If you enjoyed this article, please give it a thumbs up :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>FACTORY MACHINES</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Sun, 11 Oct 2020 05:10:06 +0000</pubDate>
      <link>https://dev.to/salonix__/factory-machines-1k9j</link>
      <guid>https://dev.to/salonix__/factory-machines-1k9j</guid>
      <description>&lt;h2&gt;PROBLEM STATEMENT:&lt;/h2&gt;

&lt;p&gt;A factory has n machines which can be used to make products. Your goal is to make a total of t products.&lt;/p&gt;

&lt;p&gt;For each machine, you know the number of seconds it needs to make a single product. The machines can work simultaneously, and you can freely decide their schedule.&lt;/p&gt;

&lt;p&gt;Find the shortest time to make t products.&lt;/p&gt;

&lt;h2&gt;APPROACH:&lt;/h2&gt;

&lt;p&gt;Let's assume that all the products are made by the maximum element present in the array, i.e., by the machine which takes the maximum amount of time just to make a single product.&lt;br&gt;
Then use a binary search to calculate the correct time.&lt;br&gt;
Consider an example, 2,3,5.&lt;br&gt;
Assume all the products are made by 3rd machine having time 5 units. So, the total time would be 5*(number of products).&lt;br&gt;
Here, we are using basic mathematics. One machine takes x unit of time to make a single product, then, in y unit of time, it will make y/x product.&lt;br&gt;
We are going to use the same approach in a binary search.&lt;/p&gt;

&lt;h2&gt;BINARY SEARCH IMPLEMENTATION LOGIC:&lt;/h2&gt;

&lt;p&gt;&lt;b&gt;STEP 1:&lt;/b&gt; Take two pointers, low and high. Set low = 0 and high = *max_element*total + 1.&lt;br&gt;
&lt;b&gt;STEP 2:&lt;/b&gt;  Create a while loop with a condition where low&amp;lt;=high.&lt;br&gt;
Find mid-value of range low to high.&lt;br&gt;
&lt;b&gt;STEP 3:&lt;/b&gt;  Calculate the number of products that can be made in "MID" time. &lt;br&gt;
&lt;b&gt;STEP 4:&lt;/b&gt;  Compare this and with the target value, if it is greater than the target, it means, we can reduce our time to some more extent, so decrement high = mid-1 and store the current answer in a variable, else if it is lower than the target, which means, we have to increase our time more, so increment low = mid+1.&lt;br&gt;
&lt;b&gt;STEP 5:&lt;/b&gt;  Output the final answer.&lt;/p&gt;

&lt;h2&gt;CODE IMPLEMENTATION &lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7heol6arpgusdit3o9i1.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7heol6arpgusdit3o9i1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HAPPY CODING :)&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Smallest KMP</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Mon, 28 Sep 2020 15:39:22 +0000</pubDate>
      <link>https://dev.to/salonix__/smallest-kmp-2hlm</link>
      <guid>https://dev.to/salonix__/smallest-kmp-2hlm</guid>
      <description>&lt;p&gt;&lt;b&gt;PROBLEM STATEMENT&lt;/b&gt;&lt;br&gt;
Reorder the characters of S in such a way that P occurs in the resulting string (an anagram of S) as a substring.&lt;br&gt;
Note: A string B is a substring of a string A if B can be obtained from A by deleting several (possibly none or all) characters from the beginning and several (possibly none or all) characters from the end.&lt;/p&gt;

&lt;p&gt;Input: &lt;br&gt;
akramkeeanany&lt;br&gt;
aka&lt;br&gt;
Output:&lt;br&gt;
aaakaeekmnnry&lt;/p&gt;

&lt;p&gt;&lt;b&gt;APPROACH&lt;/b&gt;&lt;br&gt;
Let's assume the given string be S and it's given substring be P.&lt;br&gt;
Using the hashing technique, store the occurrence of both S and P in separate hashtables. Now, remove the occurrence of S's hashtable from P's hashtable. It will give all the characters apart from that present in the P string. &lt;br&gt;
To make it more clear, see the code given below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YQ2G6fJi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogjnzwq564jtcj5m00nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YQ2G6fJi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogjnzwq564jtcj5m00nw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, make a new empty string "str" and append all the characters from the modified hashtable, it will give the string having characters different from those in P.&lt;/p&gt;

&lt;p&gt;There are three orders in which we can place P in Str:&lt;br&gt;
&lt;b&gt;Case 1:&lt;/b&gt;&lt;br&gt;
When P's first character is smaller than Str's first character,&lt;br&gt;
here, we can place p before str.&lt;br&gt;
&lt;b&gt;Case 2:&lt;/b&gt;&lt;br&gt;
When P's first character is smaller than some middle character in str, then we can P just before the character, which is strictly greater than P's first character.&lt;br&gt;
&lt;b&gt;Case 3:&lt;/b&gt;&lt;br&gt;
When P's first character is the largest one, then we have to place P after str.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Another Most Important Case&lt;/b&gt;&lt;br&gt;
When P's first character equals to some character in str, here we have two options, we can place P before that character or after that character, here we will make two string for both the cases and compare which one is larger.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;CODE IMPLEMENTATION: &lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YWlnr3Dr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ipf7udm1mp3exea5xhp6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YWlnr3Dr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ipf7udm1mp3exea5xhp6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding :)&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>cpp</category>
      <category>computerscience</category>
      <category>challenge</category>
    </item>
    <item>
      <title>CORONA VIRUS SPREAD 2</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Sun, 20 Sep 2020 07:20:05 +0000</pubDate>
      <link>https://dev.to/salonix__/corona-virus-spread-2-4pc2</link>
      <guid>https://dev.to/salonix__/corona-virus-spread-2-4pc2</guid>
      <description>&lt;p&gt;Another problem editorial from &lt;b&gt;Codechef September Long Challenge&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;PROBLEM STATEMENT:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;There are N athletes (numbered 1 through N) in a line. For each valid i, the i-th athlete starts at the position i and his speed is Vi, i.e. for any real number t≥0, the position of the i-th athlete at the time t is i+Vi⋅t.&lt;/p&gt;

&lt;p&gt;Unfortunately, one of the athletes is infected with a virus at the time t=0. This virus only spreads from an infected athlete to another whenever their positions are the same at the same time. A newly infected athlete may then infect others as well.&lt;/p&gt;

&lt;p&gt;We do not know which athlete is infected initially. Find the size of this set, i.e. the final number of infected people, in the best and worst possible scenario.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;LOGIC&lt;/b&gt;&lt;br&gt;
&lt;b&gt;Case 1:&lt;/b&gt; If the speed of two athletes is the same, they will never meet. So, in that case, we have surety that the virus won't spread amongst them.  &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Case 2:&lt;/b&gt; If the speed of an athlete at position 4 is greater than that of an athlete at position 2, then in that case also, they will never meet.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Case 3:&lt;/b&gt; If the speed of an athlete at position 4 is lesser than that of an athlete at position 2, then, in that case, they will meet.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Time Calculation: &lt;/b&gt; Time can be calculated by the formula, (pos1 - pos2)/(speed 2 - speed1)&lt;br&gt;
Now, another main point in this question is, one athlete, can only spread COVID19 to another one, only after getting infected. Hence, we can use Depth First Search.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;CODE IMPLEMENTATION&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Firstly, we will make a 2D vector array and traverse through the given array of athletes and calculate time if they will meet or not, if it is negative, or 0, we will fill -1 in the 2D matrix, else will fill the calculated time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rqzkyeQK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mkrz04xbv597d7ihmgok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rqzkyeQK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mkrz04xbv597d7ihmgok.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we will use Depth First Search Method in the following manner to find out the maximum and the minimum number of people who can get infected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O8pD7QdH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0704soh0dyl7me8fe85c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O8pD7QdH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0704soh0dyl7me8fe85c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lXa3d6Om--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hkkb6tbc2aj20uzczncd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lXa3d6Om--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hkkb6tbc2aj20uzczncd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then finally, iterate over that vector &lt;b&gt;v&lt;/b&gt; and find out the maximum and minimum element which is the required answer.&lt;/p&gt;

&lt;p&gt;That's all, Happy Coding :)&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>cpp</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Chefina and Swaps</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Sat, 19 Sep 2020 07:18:46 +0000</pubDate>
      <link>https://dev.to/salonix__/chefina-and-swaps-13pb</link>
      <guid>https://dev.to/salonix__/chefina-and-swaps-13pb</guid>
      <description>&lt;p&gt;This question came in Codechef September Long Challenge, hope you find this solution useful.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;PROBLEM STATEMENT:&lt;/b&gt;&lt;br&gt;
You are given a positive integer N. Consider the sequence S=(1,2,…,N). You should choose two elements of this sequence and swap them.&lt;/p&gt;

&lt;p&gt;A swap is nice if there is an integer M (1≤M&amp;lt;N) such that the sum of the first M elements of the resulting sequence is equal to the sum of its last N−M elements. Find the number of nice swaps.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;BRUTE FORCE APPROACH&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Firstly, find the total sum of the given array, if the sum is odd, then simply return 0, as there is no possibility to divide that array into equal half.&lt;br&gt;
Now, check for the second case, when the sum is even:&lt;br&gt;
Iterate through the array, and calculate the sum of elements of the subarray, till it would be less than on equal to half sum.&lt;br&gt;
Then calculate the number of swaps.&lt;/p&gt;

&lt;p&gt;Swaps = xC2(For first partition) + n-xC2(For second partition) + n-x(For swaps in between two partitions)&lt;/p&gt;

&lt;p&gt;This approach will give you TLE, as finding the sum of the array through iteration will take O(n) time, which can be reduced to O(1).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Optimised Approach&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the total sum as &lt;b&gt; (n*(n+1))/2 &lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Check if it is even or odd, if odd, return 0, else proceed to the next step.&lt;/li&gt;
&lt;li&gt;Now, we will calculate the sum of subarray having sum approximately half of the total sum.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the main logic of finding a sum in this question.&lt;br&gt;
Look at the following mathematics using Shri Dhanacharya equation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DMNniWFl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c2ww8yz2hbi3u0cmpsxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DMNniWFl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c2ww8yz2hbi3u0cmpsxq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will give the element up to which the sum of the subarray is approximately half of the total sum in O(1) time complexity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c25jMZ1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ppll7fcru5g06150nrjl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c25jMZ1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ppll7fcru5g06150nrjl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;fquad == quad means both the subarray have sum exactly half of the total sum, if this condition is false, the sub sum is not exactly half of the total sum, hence we need to swap elements, hence on n-x swaps would be counted.&lt;/p&gt;

&lt;p&gt;I hope you found this editorial helpful, please give me a like and follow me.&lt;br&gt;
Happy coding :)&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>cpp</category>
      <category>codenewbie</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Trie Data Structure</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Mon, 07 Sep 2020 16:10:13 +0000</pubDate>
      <link>https://dev.to/salonix__/trie-data-structure-2jml</link>
      <guid>https://dev.to/salonix__/trie-data-structure-2jml</guid>
      <description>&lt;p&gt;Trie is an efficient information re&lt;b&gt;Trie&lt;/b&gt;val data structure. Using Trie, search complexities can be brought to an optimal limit (key length). If we store keys in the binary search tree, a well-balanced BST will need time proportional to M * log N, where M is the maximum string length and N is the number of keys in the tree. Using Trie, we can search the key in O(M) time.&lt;/p&gt;

&lt;p&gt;There are many questions in strings where we should use a trie data structure, instead of other algorithms. For example, if there is a word in the dictionary, which you need to search, whether it is present or not. The most basic approach, that will come to your mind is to search the word one by one in the dictionary. &lt;br&gt;
But, if we are searching for the word "NO", and in the dictionary, we have {"Not", "Notes", "Notable", "Nope"}, then we will search character by character. Now, consider a word with 1 lakh length. If would become more complex and you will definitely get TLE, in CP. &lt;/p&gt;

&lt;p&gt;So, what you can do is, make use of the TRIE data structure. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8HTK6MVc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j0nh5k4mc2y4l9lfem9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8HTK6MVc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j0nh5k4mc2y4l9lfem9p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, what we are doing is, creating a class Node, where we have data, map, and terminal as its elements. We have an unordered map, which links the first character of the word, to all the words starting from it. For example, we have {"Apple", "Ants", "Animals", "Amphibians"}, then the map will link the character "A", with the tree which consisted of the rest of the letters as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b593KLi4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6tb1mfixaghdx4xqz2ij.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b593KLi4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6tb1mfixaghdx4xqz2ij.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we will create another class TRIE, which will create our whole tree&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xfrajAXq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f9cn9er4iom50h2m36wd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xfrajAXq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f9cn9er4iom50h2m36wd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we will create a function insert node, which will take the word as an argument, and will create the whole trie.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rwisiWbt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rfljukcpws28w38ah6hu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rwisiWbt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rfljukcpws28w38ah6hu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we defined a temp Node, which contains the root node.&lt;br&gt;
Now, we iterate through the characters in the word and will check, whether it is already present or not, if not, we create a new node and link it to our unordered_map.&lt;br&gt;
After iterating through the whole character array, make sure to put temp-&amp;gt;terminal to true, which will indicate that the word ends.&lt;/p&gt;

&lt;p&gt;That's all for the TRIE data structure.&lt;br&gt;
Happy Coding :)&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>computerscience</category>
      <category>codequality</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Maximum Bipartite Graph</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Fri, 28 Aug 2020 15:37:28 +0000</pubDate>
      <link>https://dev.to/salonix__/maximum-bipartite-graph-4k7j</link>
      <guid>https://dev.to/salonix__/maximum-bipartite-graph-4k7j</guid>
      <description>&lt;p&gt;This is the most famous question in graph theory, where you have to find the maximum number of dots in the first set, to be connected with dots in the second set, with a condition that no two nodes can be connected from first to second and vice-versa.&lt;/p&gt;

&lt;p&gt;Let me first give a brief intro about the problem statement.&lt;br&gt;
There are &lt;b&gt;M&lt;/b&gt; number of job applicants, applying for &lt;b&gt;N&lt;/b&gt; number of jobs. Each job opening can only accept one applicant and a job applicant can be appointed for only one job.&lt;/p&gt;

&lt;p&gt;The &lt;b&gt;Bruteforce Method&lt;/b&gt; is to give the job to the applicant, that is on their first priority, if there occurs any conflict, then move on to its second-most priority, and so on.&lt;br&gt;
But from this approach, we won't be able to get the maximum number of jobs to be given to the applicants.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimised Approach
&lt;/h2&gt;

&lt;p&gt;We are given a 2-D matrix, in which, if the job applicant has applied for a particular job, then it equals to 1 otherwise 0.&lt;br&gt;
First of all, we will make matchR[] array of size N(number of total jobs available) and initialize it with -1 as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WgAeJ30M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/774sr3pyjqxww2orxr5d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WgAeJ30M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/774sr3pyjqxww2orxr5d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, loop through the job applicants, and initialize another boolean array with false, named seen, it will keep track if the same job is not given to two applicants.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nijx0BLa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hrdpm4iy99vy16peb50c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nijx0BLa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hrdpm4iy99vy16peb50c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now call the function &lt;b&gt;bpm&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2cYZUDjA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/spxit2s9i1bs4qqxxhn5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2cYZUDjA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/spxit2s9i1bs4qqxxhn5.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will check the first priority of the first applicant, it will normally assign that job to him. Then we will send the second job applicant, it will check it's the first priority if his first priority is the same as that given to the previous applicant, then we will recursively call the function again and check if&lt;br&gt;
the second priority of the previous one is available,&lt;br&gt;
if is available {&lt;br&gt;
then it would be assigned to him, and our present applicant can get his first priority job.}&lt;br&gt;
otherwise {&lt;br&gt;
check for the next priority job of the same previous job applicant.&lt;br&gt;
}&lt;br&gt;
Now consider, if the previous applicant doesn't have second priority, then we don't give the job to the &lt;b&gt;present&lt;/b&gt; job applicant and will return false, and move on to next one.&lt;/p&gt;

&lt;p&gt;In this way, we can get the maximum number of jobs that can be given to the applicants.&lt;br&gt;
That's all.&lt;br&gt;
Keep reading :)&lt;br&gt;
Keep coding :)&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>computerscience</category>
      <category>devops</category>
      <category>codequality</category>
    </item>
    <item>
      <title>DBMS- Database Management System</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Mon, 24 Aug 2020 17:40:44 +0000</pubDate>
      <link>https://dev.to/salonix__/dbms-database-management-system-4mnf</link>
      <guid>https://dev.to/salonix__/dbms-database-management-system-4mnf</guid>
      <description>&lt;p&gt;A &lt;b&gt;database&lt;/b&gt; is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS). Together, the data and the DBMS, along with the applications that are associated with them, are referred to as a database system, often shortened to the database.&lt;/p&gt;

&lt;p&gt;Data within the most common types of databases in operation today is typically modeled in rows and columns in a series of tables to make processing and data querying efficient. The data can then be easily accessed, managed, modified, updated, controlled, and organized.&lt;/p&gt;

&lt;p&gt;DBMS allows the following tasks to the user:&lt;br&gt;
1.Data Definition: It helps in the creation, modification, and removal of definitions that define the organization of data in the database.&lt;/p&gt;

&lt;p&gt;2.Data Updation: It helps in insertion, modification, and deletion of the actual data in the database.&lt;/p&gt;

&lt;p&gt;3.Data Retrieval: It helps in the retrieval of data from the database which can be used by applications for various purposes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User Administration: It helps in registering and monitoring users, enforcing data security, monitoring performance, maintaining data integrity, dealing with concurrency control, and recovering information corrupted by unexpected failure. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It has the following key components: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Software: DBMS is primarily a software system that can be considered as a management console or an interface to interact with and manage databases. The interfacing also spreads across real-world physical systems that contribute data to the backend databases. The OS, networking software and the hardware infrastructure is involved in creating, accessing, managing, and processing the databases.&lt;/li&gt;
&lt;li&gt;Data: DBMS contains operational data, access to database records, and metadata as a resource to perform the necessary functionality. The data may include files such as index files, administrative information, and data dictionaries used to represent data flow, ownership, structure, and relationships to other records or objects.&lt;/li&gt;
&lt;li&gt;Procedures: While not a part of the DBMS software, procedures can be considered as instructions on using DBMS. The documented guidelines assist users in designing, modifying, managing, and processing databases.&lt;/li&gt;
&lt;li&gt;Database languages: These are components of the DBMS used to access, modify, store, and retrieve data items from databases; specify database schema; control user access; and perform other associated database management operations. Types of DBMS languages include Data Definition Language (DDL), Data Manipulation Language (DML), Database Access Language (DAL) and Data Control Language (DCL).
5.Query processor: As a fundamental component of the DBMS, the query processor acts as an intermediary between users and the DBMS data engine in order to communicate query requests. When users enter an instruction in SQL language, the command is executed from the high-level language instruction to a low-level language that the underlying machine can understand and process to perform the appropriate DBMS functionality. In addition to instruction parsing and translation, the query processor also optimizes queries to ensure fast processing and accurate results.&lt;/li&gt;
&lt;li&gt;Runtime database manager: A centralized management component of DBMS that handles functionality associated with runtime data, which is commonly used for context-based database access. This component checks for user authorization to request the query; processes the approved queries; devises an optimal strategy for query execution; supports concurrency so that multiple users can simultaneously work on the same databases; and ensures the integrity of data recorded into the databases.&lt;/li&gt;
&lt;li&gt;Database manager. Unlike the runtime database manager that handles queries and data at runtime, the database manager performs DBMS functionality associated with the data within databases. The database manager allows a set of commands to perform different DBMS operations that include creating, deleting, backup, restoring, cloning, and other database maintenance tasks. The database manager may also be used to update the database with patches from vendors.&lt;/li&gt;
&lt;li&gt;Database engine: This is the core software component within the DBMS solution that performs the core functions associated with data storage and retrieval. A database engine is also accessible via APIs that allow users or apps to create, read, write, and delete records in databases.&lt;/li&gt;
&lt;li&gt;Reporting: The report generator extracts useful information from DBMS files and displays it in a structured format based on defined specifications. This information may be used for further analysis, decision making, or business intelligence.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you for reading :)&lt;br&gt;
Keep learning :)&lt;/p&gt;

</description>
      <category>database</category>
      <category>computerscience</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to get started with Android Development?</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Wed, 19 Aug 2020 16:50:03 +0000</pubDate>
      <link>https://dev.to/salonix__/how-to-get-started-with-android-development-ig0</link>
      <guid>https://dev.to/salonix__/how-to-get-started-with-android-development-ig0</guid>
      <description>&lt;p&gt;Android development is a very vast and interesting field. If you have decided to start with android, then, first of all, check the configurations of your system, because, there are some &lt;a href="https://developer.android.com/studio"&gt;requirements&lt;/a&gt; that your system needs to satisfy to run some IDEs, for example, Android Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which language to choose?
&lt;/h2&gt;

&lt;p&gt;You can code in &lt;b&gt;Java&lt;/b&gt; as well as &lt;b&gt;Kotlin&lt;/b&gt; if you are going for native apps for android.&lt;br&gt;
There are many more resources available for app development in Java as compared to Kotlin, as Java is older than Kotlin. But Kotlin makes your code short and simple. &lt;br&gt;
So, according to me, first, learn android development in Java, then switch to Kotlin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which IDE to choose?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Visual Studio – Xamarin&lt;/li&gt;
&lt;li&gt;Android Studio&lt;/li&gt;
&lt;li&gt;IntelliJ IDEA&lt;/li&gt;
&lt;li&gt;DeuterIDE&lt;/li&gt;
&lt;li&gt;Eclipse IDE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are a beginner, then go for Android Studio. After completing your learning process, you can switch to Visual Studio.&lt;/p&gt;

&lt;p&gt;Now, moving on to the question, how to get started. &lt;br&gt;
Begin with the following topics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;User inputs&lt;/b&gt; - This topic will cover all types of inputs that you can take in your application. For example, usernames, password, text input, email input, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Multiple Activity&lt;/b&gt; - Here, you will get to learn about how to switch to next activity/screen. For example, when you click on the login button of Instagram(Let's say), you get to see another screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Internet Connectivity&lt;/b&gt; - In this topic, you will get to learn how to connect your application with the internet, how to get extract data from APIs, and use it in your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Data Storage&lt;/b&gt; - There are several options for data storage eg. MongoDB, MySQL, Firebase, and many more. For a beginner, I would suggest going with Firebase as it is very easy to use. After that, you can switch to MongoDB or MySQL, these two databases are too interesting and wide. You have to give enough time to them to understand properly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And congrats, you are a beginner/medium level android developer (depending upon your learnings). &lt;br&gt;
One more thing I would like to add is, please focus more on UI designing, because I personally feel that in android development, the front end should be more attractive. &lt;/p&gt;

&lt;p&gt;If you like this blog, please give me a like and follow me :)&lt;/p&gt;

</description>
      <category>android</category>
      <category>devops</category>
      <category>computerscience</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Tree Views</title>
      <dc:creator>Saloni Gupta</dc:creator>
      <pubDate>Mon, 17 Aug 2020 17:17:54 +0000</pubDate>
      <link>https://dev.to/salonix__/tree-views-2aij</link>
      <guid>https://dev.to/salonix__/tree-views-2aij</guid>
      <description>&lt;p&gt;I was going through some coding problems related to Views(Top view, Left View, Bottom View, and Right View). So, I decided to share my knowledge with you guys. Keep reading :)&lt;/p&gt;

&lt;p&gt;Firstly, let me introduce each view with a brief description.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;b&gt;top view&lt;/b&gt; of a binary tree is the set of nodes visible when the tree is viewed from the top. &lt;/li&gt;
&lt;li&gt;The &lt;b&gt;left view&lt;/b&gt; of a binary tree is the set of nodes visible when the tree is viewed from left.&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;right view&lt;/b&gt; of a binary tree is the set of nodes visible when the tree is viewed from right.&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;bottom view&lt;/b&gt; of a binary tree is the set of nodes visible when the tree is viewed from bottom.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Top View
&lt;/h2&gt;

&lt;p&gt;Steps to find Top View:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a queue and a map.&lt;/li&gt;
&lt;li&gt;Push the root node inside the queue.&lt;/li&gt;
&lt;li&gt;In class Tree, initialize int hd = 0 as its member.&lt;/li&gt;
&lt;li&gt;Now map the value with of root with its hd(Horizontal Distance). &lt;/li&gt;
&lt;li&gt;Now make a while loop which will run until the queue becomes empty.&lt;/li&gt;
&lt;li&gt;Now pop out the element and check if hd count in map == 0, then map it with its horizontal distance i.e., hd.&lt;/li&gt;
&lt;li&gt;Check whether it has left child, if yes then firstly map the root-&amp;lt;left value with hd-1, and then push it in the queue.&lt;/li&gt;
&lt;li&gt;Similarly, check for the right child, and map it with hd+1, and push inside the queue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What we are doing here is, we have defined horizontal distance of root node = 0, as we move leftwards, its horizontal distance decreases by 1 and for rightwards, its horizontal distance increases by 1. Then in Step 6, we are checking if the element is already present at that horizontal distance or not, if it is present, then we don't map the root value with hd. As we want only the top view nodes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ujV-1tHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2chz41j8a1gy4zivbbou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ujV-1tHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2chz41j8a1gy4zivbbou.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Refer to this image to understand horizontal distance in a better way.&lt;/p&gt;

&lt;p&gt;I Will Continue this topic for next type of views, as I like to keep my blog short, so stay connected and please follow me for new updates :)&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>codepen</category>
      <category>computerscience</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
