<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Drashti Koladiya on Medium]]></title>
        <description><![CDATA[Stories by Drashti Koladiya on Medium]]></description>
        <link>https://medium.com/@drashtikoladiya?source=rss-3ce6939bc4a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Pl-9OMX6xvn-k5Xf_BXfJA.jpeg</url>
            <title>Stories by Drashti Koladiya on Medium</title>
            <link>https://medium.com/@drashtikoladiya?source=rss-3ce6939bc4a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:51:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@drashtikoladiya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My Microsoft Interview Experience for Summer Internship]]></title>
            <link>https://levelup.gitconnected.com/my-microsoft-interview-experience-for-summer-internship-4c8ff98db556?source=rss-3ce6939bc4a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c8ff98db556</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[interview-experience]]></category>
            <dc:creator><![CDATA[Drashti Koladiya]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 21:47:01 GMT</pubDate>
            <atom:updated>2022-12-09T12:16:56.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Microsoft logo" src="https://cdn-images-1.medium.com/max/1024/1*bRzNzI5b2gTo_qpnwJS9Ug.png" /></figure><p>My microsoft interview experience for the summer internship’22. The interview consisted of two technical and 1 technical+HR round.</p><h3>Technical round 1</h3><ol><li>Given a linked list which is sorted in ascending order, construct the balanced binary search tree.</li><li>Sort the linked list.</li></ol><h3>Technical round 2</h3><ol><li>You are given a matrix of 0’s and 1’s, you have to return the total number of unique rows in the matrix. <em>There are two optimal solutions of this given problem. 1) String hashing 2) Using Trie</em></li><li><em>Follow up question: — Now, You need to print all the unique rows.</em></li><li>You are given a dictionary of words, a source word and destination node. At any point of time you can only change one character of the current node. Find the length of the shortest path between the source word and the destination word. Return -1 if no path exists.</li><li>You are given an array of strings you need to return all the shortest unique prefixes to represent each word.</li></ol><h3>Technical + HR round 3</h3><ol><li>Project and scenario based questions</li><li>Questions from resume</li></ol><h4>HR questions</h4><ol><li>Tell me about yourself.</li><li>What interests you the most.</li><li>I was given one scenario to build a project and what are the basic requirements and optimizations that I needed to do.</li></ol><blockquote>I hope you found it useful. Thanks for reading :)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c8ff98db556" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/my-microsoft-interview-experience-for-summer-internship-4c8ff98db556">My Microsoft Interview Experience for Summer Internship</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Different Ways To Solve Trapping Rain Water Problem]]></title>
            <link>https://levelup.gitconnected.com/4-different-ways-to-solve-trapping-rain-water-problem-c69c09e4f96b?source=rss-3ce6939bc4a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c69c09e4f96b</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Drashti Koladiya]]></dc:creator>
            <pubDate>Tue, 26 Oct 2021 14:01:24 GMT</pubDate>
            <atom:updated>2021-10-28T03:45:14.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1CK2UX5_LcMaloz2" /></figure><p>Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.</p><p>We are going to look at 4 different approaches to solve the above problem and for that, we will follow the given input test case</p><p>Input: a = [1,0,2,1,0,1,3,2,1,2,1]</p><p>Have a look at the picture below to understand how much water will be trapped in between the bars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fu1MEoR-gBqTvBDh" /><figcaption>Understanding how the water will get trapped at each index | image by author</figcaption></figure><h4>Let’s first understand the intuition behind the problem.</h4><ul><li>Observe the above picture carefully, You will notice that for water to get trapped at the ith bar it should have a higher bar both on its left side as well as on the right side.</li><li>To find the amount of the water that gets trapped at the ith index we need to find the maximum element on its left side that is max(a[1],…a[i]) and the maximum element on its right side that is max(a[i]…a[n]).</li><li>Now, if the height of the bar at ith index is a[i] then the water that gets trapped at ith index will be</li></ul><blockquote><strong>min(leftmax ,rightmax) — a[i]</strong></blockquote><blockquote><strong>min(max(a[1],…a[i]),max(a[i]…a[n])) — a[i]</strong></blockquote><p>Refer to the picture below for a better understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlG4VE4rX8Dbuv8QaAGqWA.png" /><figcaption>Image by author</figcaption></figure><p>We can do a summation of water that has been trapped at every ith index and find the total amount of water that is actually trapped.</p><p>Now, as you understood the problem statement and intuition behind it let’s jump to the first and the most naive approach.</p><h3>Brute Force:</h3><p>For every ith index first, we will find the maximum element on its left side as well the maximum element on its right side and then the water that can be trapped at ith index.</p><p>Refer to the code below for the above approach.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0573cb2e7724a8aae1ae053bd79fbbb6/href">https://medium.com/media/0573cb2e7724a8aae1ae053bd79fbbb6/href</a></iframe><p><strong>Time Complexity: O(N²)</strong></p><p><strong>Space Complexity: O(1)</strong></p><p>Can we do better? Let’s have look at the below approach:</p><h3><strong>Prefix sum based Optimal approach:</strong></h3><p>Instead of finding the leftmax and rightmax for every index i, we can precompute the leftmax and rightmax for every index i. How? see the below steps!</p><ul><li>We will create 2 arrays <strong><em>prefix</em> </strong>and <strong><em>suffix</em></strong> of size n.</li><li><strong><em>prefix[i]</em></strong> will store <strong><em>max(a[1],…a[i])</em>.</strong></li><li><strong><em>suffix[i]</em></strong> will store <strong><em>max(a[i],…a[n]).</em></strong></li></ul><p>Now, we can iterate over the input array and find the total water trapped in between the bars.</p><p>Refer to the code for the above approach.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a28c04065c6e26ee0f6e307f2959809/href">https://medium.com/media/7a28c04065c6e26ee0f6e307f2959809/href</a></iframe><p><strong>Time Complexity: O(N)</strong></p><p><strong>Space Complexity: O(N)</strong></p><p>Can you think of another approach with the same complexity!</p><h3>Stack-based approach:</h3><p>This approach is based on the famous interview problem <a href="https://leetcode.com/problems/largest-rectangle-in-histogram/">largest rectangle in histogram.</a></p><p>Follow the steps below to understand the approach.</p><ul><li>Find the <strong><em>nearest greater element to the left side</em></strong> of the ith element and the <strong><em>nearest greater or equal element to the right side</em></strong> of the ith element.</li><li>If the index of leftmax is x and index of the rightmax is y, Add (min(leftmax,rightmax)-a[i])*(y-x-1) to the total trapped water. Didn’t get it? Refer to the image below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a14_gFUoJAsNN1puCJr-mQ.png" /><figcaption>Image by author</figcaption></figure><p>Refer to the code for the above approach:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fd44ed0f0d3e07b1df60bea74f0e872/href">https://medium.com/media/9fd44ed0f0d3e07b1df60bea74f0e872/href</a></iframe><p><strong>Time Complexity: O(N)</strong></p><p><strong>Space Complexity: O(N)</strong></p><p>Still not satisfied with the above complexity? Let’s have a look at a more space-optimized approach.</p><h3><strong>Two Pointer Approach:</strong></h3><p>In the 2nd approach, we have used extra space to store the precomputed values of leftmax and rightmax for every index i.</p><p>Instead, we can keep 2 variables leftmax and rightmax. Now we can define our range by low=1 and high=n.</p><ul><li>If<strong> <em>a[low] ≤ a[high]</em></strong> then we know that there is some element greater than a[low] to its right side and from the formula <strong><em>min(leftmax , rightmax) — a[i]</em></strong> we will consider<strong> <em>leftmax-a[low]</em></strong> into trappedwater and <strong><em>increment our low pointer.</em></strong></li><li>If <strong><em>a[low] &gt; a[high]</em></strong> then we know that there is some element greater than a[high] to its leftside and from the formula <strong><em>min(leftmax , rightmax) — a[i]</em></strong> we will consider <strong><em>rightmax-a[high]</em></strong> into trappedwater and <strong><em>decrement our high pointer</em></strong>.</li></ul><p>Refer to the code for the above approach for better understanding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d7911d68392739fd9b9794cfa934748/href">https://medium.com/media/0d7911d68392739fd9b9794cfa934748/href</a></iframe><p><strong>Time Complexity: O(N)</strong></p><p><strong>Space Complexity: O(1)</strong></p><p>I hope now you got a clear understanding of the Trapping rain water problem.</p><p>Thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c69c09e4f96b" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/4-different-ways-to-solve-trapping-rain-water-problem-c69c09e4f96b">4 Different Ways To Solve Trapping Rain Water Problem</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the Difference between String, StringBuilder, and StringBuffer?]]></title>
            <link>https://medium.com/quick-code/what-is-the-difference-between-string-stringbuilder-and-stringbuffer-6b8a998f6eae?source=rss-3ce6939bc4a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8a998f6eae</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[stringbuffer]]></category>
            <category><![CDATA[string]]></category>
            <category><![CDATA[diffrence]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Drashti Koladiya]]></dc:creator>
            <pubDate>Wed, 20 Oct 2021 18:22:47 GMT</pubDate>
            <atom:updated>2021-11-18T16:49:06.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*6mIvQQXXr7UYXw0W" /></figure><h4><strong>What is the difference between String, StringBuilder, and StringBuffer?</strong></h4><p>Let’s first understand what String, StringBuilder, and StringBuffer are.</p><h3><strong>String</strong></h3><ul><li>A String in Java is an object which represents a sequence of characters.</li><li>Java String is immutable which means once it is declared it cannot be changed</li><li>We can create String objects in 2 ways. 1) By using String literal, 2) By new Keyword.</li><li>String objects in Java are stored in a space called String constant pool. If the string already exists in the pool, a reference to the pooled instance is returned.</li></ul><p>Let’s see an example below to understand the immutability and different ways to create a Java String object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0PpEiHGCXinUZ3V" /><figcaption>Immutability of string</figcaption></figure><h3><strong>StringBuilder</strong></h3><ul><li>Similar to Strings, StringBuilder is also an object which represents the sequence of characters.</li><li>Java StringBuilder class is used to create mutable String.</li><li>Apart from that Java StringBuilder class is not thread-safe it means it doesn’t guarantee synchronization.</li></ul><p>The below example shows the mutability of the StringBuilder class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tLaZNBIa1NFK0eE6" /><figcaption>The mutability of the StringBuilder class</figcaption></figure><p>The below example shows why StringBuilder is not thread-safe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*USqGWeZWr5rAHWVX" /><figcaption>Example of how StringBuilder class is not thread-safe</figcaption></figure><p>As we can see that we have 2 threads and each of them adds 50000 “A” characters so the ideal length of the resulting string should be 100000 but it is 98885 which is unexpected. Thus, we can clearly say that the StringBuilder class is not thread-safe.</p><h3><strong>StringBuffer</strong></h3><ul><li>Similar to StringBuilder, StringBuffer is also an object which represents the sequence of characters, and it is used to create mutable String.</li><li>Java StringBuffer class is thread-safe. It means multiple threads can not access it at the same time and it guarantees synchronization.</li></ul><p>The below example shows how the StringBuffer class is thread-safe and mutable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hQqBXYVNpHS6ZJRn" /><figcaption>Thread-safe and mutable StringBuffer class</figcaption></figure><p>Here, we can see that we have 2 threads and each of them adds 50000 “A” characters so the ideal length of the resulting string should be 100000 and it is 100000. Thus, we can clearly say that the StringBuffer class is thread-safe.</p><h4>We can summarize the difference between String, StringBuilder, and StringBuffer as follows.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*r3jfVMjoPZH9s2xXdLZdsw.png" /><figcaption>Difference between String, StringBuilder, and StringBuffer</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8a998f6eae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quick-code/what-is-the-difference-between-string-stringbuilder-and-stringbuffer-6b8a998f6eae">What is the Difference between String, StringBuilder, and StringBuffer?</a> was originally published in <a href="https://medium.com/quick-code">Quick Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>