<?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 Sia on Medium]]></title>
        <description><![CDATA[Stories by Sia on Medium]]></description>
        <link>https://medium.com/@dassayani301?source=rss-99d2e345f475------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ODSoSBFFOg30pSSmJb3hIA.jpeg</url>
            <title>Stories by Sia on Medium</title>
            <link>https://medium.com/@dassayani301?source=rss-99d2e345f475------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:33:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dassayani301/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[# Striver SDE Challenge- Day 5/45]]></title>
            <link>https://medium.com/@dassayani301/striver-sde-challenge-day-5-45-b973bee602eb?source=rss-99d2e345f475------2</link>
            <guid isPermaLink="false">https://medium.com/p/b973bee602eb</guid>
            <dc:creator><![CDATA[Sia]]></dc:creator>
            <pubDate>Tue, 09 Jun 2026 09:08:38 GMT</pubDate>
            <atom:updated>2026-06-09T09:08:38.278Z</atom:updated>
            <content:encoded><![CDATA[<p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>### Challenges for Day 5:</p><p>- Search in a 2D Matrix<br>- Power(x,n)<br>- Majority Element</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>## 1. Search in a 2D Matrix</p><p>### Problem Overview:<br>Given an m × n integer matrix where:<br>- Each row is sorted in non-decreasing order.<br>- The first element of each row is greater than the last element of the previous row.</p><p>Return true if the target exists in the matrix, otherwise return false.</p><p>The expected time complexity is O(log(mn)).</p><p>### Intuition:<br>The matrix behaves like a sorted 1D array if viewed row by row. Since the entire matrix is sorted, Binary Search immediately becomes the optimal choice.</p><p>### Challenge:<br>Binary Search is usually performed on a 1D array. The challenge here is converting a 1D index into a valid row and column index.</p><p>### Approach:<br>Treat the matrix as a virtual sorted array.</p><p>For a given middle index:</p><p>row = mid / n</p><p>col = mid % n</p><p>Using these indices, access the middle element and continue Binary Search accordingly.</p><p>Time Complexity: O(log(mn))</p><p>Space Complexity: O(1)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>2. Power(x,n)</p><p>Problem Overview:<br>Implement pow(x,n) which calculates x raised to the power n without using any built-in power function.</p><p>Intuition:<br>A naive solution multiplies x exactly n times resulting in O(n) complexity.</p><p>However, if we observe carefully:</p><p>x⁸ = (x⁴)²</p><p>x⁴ = (x²)²</p><p>We repeatedly divide the exponent by 2.</p><p>Challenge:<br>Handling very large exponents and negative powers efficiently.</p><p>Approach:<br>Use Binary Exponentiation.</p><p>- If n is even:<br> — xⁿ = (x²)ⁿ⁄²<br>- If n is odd:<br> — xⁿ = x × (x²)ⁿ⁻¹⁄²</p><p>For negative powers:<br>- Convert n to positive.<br>- Return 1/answer.</p><p>Time Complexity: O(log n)</p><p>Space Complexity: O(1)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>## 3. Majority Element</p><p>### Problem Overview:<br>Given an array nums, find the element that appears more than ⌊n/2⌋ times.</p><p>### Intuition:<br>Since the majority element appears more than half the time, it cannot be completely cancelled out by other elements.</p><p>### Challenge:<br>Finding the majority element without using extra space.</p><p>### Approach:<br>Use Boyer-Moore Voting Algorithm.</p><p>Maintain:<br>- candidate<br>- count</p><p>Rules:<br>- If count becomes 0, choose current element as candidate.<br>- If current element equals candidate, increment count.<br>- Otherwise decrement count.</p><p>The final candidate will always be the majority element.</p><p>Time Complexity: O(n)</p><p>Space Complexity: O(1)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p># Day 5 Completed ✅</p><p>Today’s problems focused on Binary Search optimization, Mathematical Computation using Divide &amp; Conquer, and Array Majority Detection using Boyer-Moore Voting Algorithm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b973bee602eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Striver SDE Sheet Challenge -4/45]]></title>
            <link>https://medium.com/@dassayani301/striver-sde-sheet-challenge-4-45-6d489dd67901?source=rss-99d2e345f475------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d489dd67901</guid>
            <category><![CDATA[sdesheetchallenge]]></category>
            <category><![CDATA[sad]]></category>
            <dc:creator><![CDATA[Sia]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 06:38:59 GMT</pubDate>
            <atom:updated>2026-06-04T06:38:59.188Z</atom:updated>
            <content:encoded><![CDATA[<p>I am documenting my process of how I solve a problem,what my approach looks like and what things I look for to solve a particular problem.</p><p>Today’s Challenge contains the following. problem:</p><ol><li>Find the repeating number</li><li>Find the duplicate and missing number</li><li>Count Inversions</li></ol><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>1.Find the Repeating Number</h3><p>Problem Overview:One number repeat atleast two times in an array, find the number</p><p>My initial Approach:</p><p>Two -pointers approach- take one pointer i at 0 and j at i+1, then continue to iterate and compare, so my code looked like this:</p><pre> for(int i=0;i&lt;nums.length-1;i++){<br>        for(int j=i+1;j&lt;nums.length;j++){<br>            if(nums[i]==nums[j]){<br>               return nums[i];<br>            }<br>            else{<br>                continue;<br>            }</pre><p>Problem. with this approach:</p><p>This produces a time complexity of O(n²), making it fail for some large cases.</p><p>Revised Strategy:</p><p>Change the data strcture to Hashset .</p><p>So , now the algorithm Becomes</p><pre>1. Iterate through the set<br>2.Check if it contains the  specific number<br>3.if yes, return the number<br>4.if no, add this to the set<br>5.ultimately  if no number is found return -1</pre><p>Thus the code becomes:</p><pre>for(int i:nums){<br>        if (set.contains(i)){<br>            return i;<br>        }<br>        set.add(i);<br>     }<br>     return -1;  </pre><p>This achieves a time complexity of O(n).</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p><strong>2.Find the duplicate and the missing number</strong></p><p>Problem Overview:</p><p>Given an array of integers, you have to find the number that duplicates itself and the number that is missing from the array.</p><p>Intuition:</p><p>This problem is a combination of find repeating numbers and two sum.</p><p>Approach:</p><ol><li>First find the number that repeats itself : this solves first half of the problem</li><li>To solve the second half, we will check the number not present in the array from the list of integers instead of two sum approach.</li></ol><p>Reasoning: Since the array contains duplicate numbers, hoping onto the two sum approach will cause irregularities in the approach .</p><p>So my final algorithm becomes:</p><pre> for(int i:nums){<br>         if(set.contains(i)){<br>                result[0]=i;<br>            }<br>            set.add(i);<br>        }<br>        int n = nums.length;<br>  for (int i = 1; i &lt;= n; i++) {<br>            if (!set.contains(i)) {<br>                result[1] = i; <br>                break;<br>            }<br>        }</pre><p>this achieves complexity of O(n).</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>3.Count Inversions</h4><p>Problem Overview:</p><p>Given an array, some elements are jumbled up,Return the <strong>number </strong>of <strong>inversions </strong>in the array where two elements <strong>a[i]</strong> and <strong>a[j] </strong>form an <strong>inversion </strong>if <strong>a[i] &gt; a[j]</strong> and <strong>i &lt; j</strong>.</p><p>Approach:</p><p>Use merge sort and sort the array in halves.</p><p>This is usually done by merge sort , but here we have to return the count of the inversions</p><p>So, the revised algorithm becomes:</p><pre>mergeSort(int[] arr, int low, int high) {<br>        long count = 0;<br><br>        if (low &lt; high) {<br>            int mid = low + (high - low) / 2;<br><br>            count += mergeSort(arr, low, mid);<br>            count += mergeSort(arr, mid + 1, high);<br>            count += merge(arr, low, mid, high);<br>        }<br><br>        return count;<br>    }</pre><p>This gives a complexity of O(n log n).</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>This concludes my day 4, stay tuned for day 5.🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d489dd67901" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The beginning is the end, the end is the beginning..]]></title>
            <link>https://medium.com/@dassayani301/the-beginning-is-the-end-the-end-is-the-beginning-dc79937a73ed?source=rss-99d2e345f475------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc79937a73ed</guid>
            <category><![CDATA[post-exam]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Sia]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 19:14:44 GMT</pubDate>
            <atom:updated>2026-06-02T19:14:44.918Z</atom:updated>
            <content:encoded><![CDATA[<p>I am relating to this line quite a lot more than usual, luckily for the past 6 months having a quite lot of things on my plate.</p><p>Not that I am complaining ,I genuinely like having some sort of work to do rather than just sitting idle.</p><p>Today, or rather yesterday, my end sems finally got over, this semester was unsually fun and weird at the same time, moved to a new section, made new friends, but the end Sem examinations were a bit weird, unusual topics(lesser known in PYQS) appeared more, exams were very much postponed leading to my patience level just at the tip and I had no time for self growth in this semester.</p><p>Now, I have quite some things in mind !!Some opportunities, a CV refresh, new opportunities in Content Creation, something that defines me or something that makes me unique!!</p><p>I want to explore everything , experience everything but life is tied up to constraints and I am wondering my aging line .Well, I will discuss separately on any other day about what I mean by that.</p><p>For now , the goal is consistency and being myself after a long!!🚀</p><p>Stayed tuned to find out what happens next!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc79937a73ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>