<?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 Devhub on Medium]]></title>
        <description><![CDATA[Stories by Devhub on Medium]]></description>
        <link>https://medium.com/@devhub2024?source=rss-7497e53d6711------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zlHpfGRbSsEUh1IF</url>
            <title>Stories by Devhub on Medium</title>
            <link>https://medium.com/@devhub2024?source=rss-7497e53d6711------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:26:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devhub2024/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[System Design Day 1- Designing a Book Selling application]]></title>
            <link>https://medium.com/@devhub2024/system-design-day-1-designing-a-book-selling-application-d9be82fc20bc?source=rss-7497e53d6711------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9be82fc20bc</guid>
            <category><![CDATA[spring-application]]></category>
            <category><![CDATA[system-design-project]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[java-applications]]></category>
            <dc:creator><![CDATA[Devhub]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 09:03:55 GMT</pubDate>
            <atom:updated>2025-09-02T09:03:55.385Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s always a thrill to put the theory into practice.</p><p>Lately I have been trying to deepen my knowledge on several aspects related to the industry level backend development.</p><p>As a part of it I am working on a project that is a basic book selling application. I have started the design part for this application recently.</p><p>Here I have designed the application in high-level and worked a bit on the low-level design as well. It is a project that is still in progress, but I would love to get some peer recommendation.</p><p>High-Level Design</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqEsufp5AdrKFEYzzTH2UQ.jpeg" /></figure><ul><li>Here I have designed an overall system design with probable systems and their communications.</li></ul><p>Communication -Design:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZux4j2Gb1oGktzt9eXQOA.jpeg" /></figure><ul><li>I have decided to use Kafka for this app as I consider it as Event-driven architecture.</li><li>As this is a project still in process, I have designed the LLD for one of the services and planning to proceed with it before jumping to the next Services.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*2WknqrLxaycWYsBXWCk-qA.jpeg" /></figure><p>For more Details: <a href="https://github.com/santhosh25420/bookito">https://github.com/santhosh25420/bookito</a></p><p>Reach out to me: <a href="http://www.linkedin.com/in/santhosh-kumar-01a5a8195">www.linkedin.com/in/santhosh-kumar-01a5a8195</a></p><p>PEACE OUT BUDS!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9be82fc20bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode:26 — Remove Duplicates from sorted Array]]></title>
            <link>https://medium.com/@devhub2024/leetcode-26-remove-duplicates-from-sorted-array-e7f0c32427be?source=rss-7497e53d6711------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7f0c32427be</guid>
            <dc:creator><![CDATA[Devhub]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 14:12:27 GMT</pubDate>
            <atom:updated>2025-08-22T14:12:27.300Z</atom:updated>
            <content:encoded><![CDATA[<h3>Leetcode:26 — Remove Duplicates from sorted Array</h3><p>Hey Folks. I am back with the classic Leetcode array problem.</p><p>Removing duplicates from a sorted Array.</p><p>For you reference I will attach the problem link here: <a href="https://leetcode.com/problem-list/nfkpb3yh/">https://leetcode.com/problem-list/nfkpb3yh/</a></p><p>It sounds simple when we read the question, but it is a little bit twisted if you have read the question completely.</p><p>We don’t directly remove the elements we rearrange them.</p><p>Let’s say we have an array [1,1,2,2,3,3,4]</p><p>the resultant array should be [1,2,3,4,_,_,_] remember the “_” is just for understanding the requirement we don’t have to replace the elements with “_”.</p><p>So here I went with a classic two pointer approach</p><pre>## Approach:<br> - Here we go with a simple two pointer approach<br> - we initialize two pointer i and j and another value to track the last updated index<br> - we compare the array elements with the index<br> - when we encounter the different elements we got the unique one<br> - so we just shift the element at index j to the index of last updated index</pre><pre>public static int getTheUniques(int[] arr){<br>        int i=0, j=1, lastUpdated =1;<br><br>        while(j&lt;arr.length){<br>            if(arr[i] != arr[j]){<br>                arr[lastUpdated]=arr[j];<br>                i = j;<br>                j++;<br>                lastUpdated++;<br>            }else{<br>                j++;<br>            }<br>        }<br>        for(int k=0;k&lt;lastUpdated;k++){<br>            System.out.print(arr[k]+&quot; &quot;); // just to understand the execution<br>        }<br>        return lastUpdated;<br>    }</pre><p>I know there has to be a better approach than this let me know if you find one. It was an easy one only I know.</p><p>PEACE OUT!!</p><p>You can reach out to me through:</p><p><a href="http://linkedin/">www.linkedin.com/in/santhosh-kumar-01a5a8195</a></p><p><a href="https://github.com/santhosh25420">https://github.com/santhosh25420</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7f0c32427be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LinkedList- Finding nth node from End.]]></title>
            <link>https://medium.com/@devhub2024/linkedlist-finding-nth-node-from-end-57f33e2429c7?source=rss-7497e53d6711------2</link>
            <guid isPermaLink="false">https://medium.com/p/57f33e2429c7</guid>
            <category><![CDATA[linked-list-operations]]></category>
            <category><![CDATA[linkedlist-in-java]]></category>
            <category><![CDATA[dsa-training]]></category>
            <category><![CDATA[dsa-courses]]></category>
            <category><![CDATA[linked-list-program]]></category>
            <dc:creator><![CDATA[Devhub]]></dc:creator>
            <pubDate>Wed, 14 May 2025 11:30:49 GMT</pubDate>
            <atom:updated>2025-05-14T11:30:49.559Z</atom:updated>
            <content:encoded><![CDATA[<p>LinkedList- Finding nth node from End.</p><p>Hello there Coders,</p><p>I am working my way through the top of the ladder of any Developer.</p><p>In that I am trying to get my head around the OG “DSA”</p><p>I am planning to write my learning curve and the stuffs I have learned and the problem I have solved in this space. Hoping to be helpful (but really, I just love writing).</p><p>So here we go for the classic Find the Nth node from the end of the Linked List.</p><p>Let’s say we have a linked list of 4 values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYp3YttBocp2lFNfG-6v9A.jpeg" /></figure><p>here if I want to find the 2nd Node from the end that is 3. What are the approaches I can take up?</p><p>There are several approaches let’s talk about the three I have used and let’s go from the brutal “Brute Force” approach.</p><pre>/*<br>    * Start iteration from the head of the node<br>    * for each iteration calculate the number of remaining nodes in the list from the current node<br>    * if the number of node is less than n-1 value return null;<br>    * if the number of nodes is grater than n-1 value continue the iteration<br>    * if the number of node is equal to the n-1 value return the node;<br>    * time complexity: O(n^2)<br>    * Space complexity: O(1)<br>     */<br>    public static Node bruteForce(int n, LinkedList list){<br>        Node temp = list.getHead();<br>        Node current;<br>        int secondaryLength=0;<br>        while(secondaryLength!= n-1){<br>            secondaryLength=0;<br>             current = temp.getNext();<br>            while(current != null){<br>                secondaryLength++;<br>                current= current.getNext();<br>            }<br>            if(secondaryLength&lt;n-1){<br>                System.out.println(&quot;Fewer&quot;);<br>                return null;<br>            }else if(secondaryLength&gt;n-1){<br>                temp = temp.getNext();<br>            }<br>        }<br>        return temp;<br>    }</pre><p>As you can see here, we must iterate through the Linked list a humungous number of times as a loop within another loop.</p><p>So, what we do here is that we iterate through each node of the list and check for the number of nodes after them and compare that number with the n-1 value and based on that comparison we find out the result.</p><p>All right let’s jump into the better approach.</p><pre>/*<br>    * More Efficient approach<br>    * Calculate the length of the list as M<br>    * Calculate new M with the formula M = (M-n)+1{Formula is used to identify the nth node from the beginning of the list<br>    * Iterate through the list until new M and return the node<br>    * time complexity: O(n)<br>    * space complexity: O(1)<br>     */<br>    public static Node  betterVersion(int n, LinkedList list){<br>        int newPosition=0;<br>        Node temp = list.getHead();<br>        while(temp != null){<br>            temp = temp.getNext();<br>            newPosition++;<br>        }<br>        if(n&gt;newPosition){<br>            return null;<br>        }<br>        newPosition= (newPosition-n)+1;<br>        int grower=1;<br>        temp = list.getHead();<br>        while(newPosition!= grower){<br>            temp = temp.getNext();<br>            grower++;<br>        }<br>        return temp;<br>    }</pre><p>This one is more of a mathematical approach. For the given list and the given nth Node, we produce the value that represents the nth node from the beginning of the list. For that first we need the length of the list. Then based on the length of the list we produce the value that represent the nth node from the beginning of the list.</p><p>We use a Formula for the, M = (M+n)-1 where M being the length of the list.</p><p>Remember I called it mathematical approach.</p><p>Yet this is not the best approach we can come up with why?</p><p>Because we scan through the list twice in this approach.</p><p>We can improve this even more. HOW?</p><p>Let’s see</p><pre> /*<br>    * The classic Two Pointer Approach<br>    * Initiate Two Pointers fast,slow both pointing to the head node<br>    * iterate the fast pointer for n times<br>    * once the fast pointer has reach n iterations start iterating the slow pointer as well<br>    * continue the simultaneous iteration until fast is equal to null<br>    * return the slow pointer<br>     */<br>    public static Node mostEfficientOrTwoPointer(int n, LinkedList list){<br>        Node fast = list.getHead();<br>        Node slow = list.getHead();<br>        int moves =0;<br><br>        while(fast != null){<br>            fast = fast.getNext();<br>            moves++;<br>            if(moves&gt;n){<br>                slow=slow.getNext();<br>            }<br>        }<br>        return slow;<br>    }</pre><p>So here we go, we got the OG Two Pointer.</p><p>Here we got two pointer: fast and slow(I gotta name my variables better sorry) they both point to the head at the beginning. The fast pointer fist moves n times ahead of the slow pointer by that we create a window that hold n nodes in them. So, when we move that window to the end of the list, we get the nth node of the list from the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8W2bPwcvKUdU7Ug9qzIEKw.jpeg" /></figure><p>So yes, that’s all as easy as it is.</p><p>Peace out guys. You can reach out to me <a href="https://www.threads.com/@dev_hub2000">https://www.threads.com/@dev_hub2000</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57f33e2429c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>