<?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: Sudeep .U</title>
    <description>The latest articles on DEV Community by Sudeep .U (@sudeep_c0d3s).</description>
    <link>https://dev.to/sudeep_c0d3s</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%2F2800569%2F1877d98f-bd0e-4a8f-9dea-862f100d8fac.png</url>
      <title>DEV Community: Sudeep .U</title>
      <link>https://dev.to/sudeep_c0d3s</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sudeep_c0d3s"/>
    <language>en</language>
    <item>
      <title>Binary Search - Check rotated sorted array</title>
      <dc:creator>Sudeep .U</dc:creator>
      <pubDate>Sat, 28 Jun 2025 18:20:27 +0000</pubDate>
      <link>https://dev.to/sudeep_c0d3s/binary-search-check-rotated-sorted-array-498k</link>
      <guid>https://dev.to/sudeep_c0d3s/binary-search-check-rotated-sorted-array-498k</guid>
      <description>&lt;p&gt;Key points :&lt;br&gt;
1) Find count of pivot elements&lt;br&gt;
2) Edge case - check last element &amp;gt; first element &lt;br&gt;
   To check this - num[i] &amp;gt; num[(i+1)%nums.length]&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 boolean check(int[] nums) {
    int c = 0;
    for(int i = 0;i &amp;lt; nums.length; i++){
        if(nums[i] &amp;gt; nums[(i+1)%nums.length]){
            c++;
        }
        if(c &amp;gt; 1){
            return false;
        }
    }
    return true;

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

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>leetcode</category>
      <category>snippet</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Binary Search -Matrix Search</title>
      <dc:creator>Sudeep .U</dc:creator>
      <pubDate>Thu, 26 Jun 2025 17:43:59 +0000</pubDate>
      <link>https://dev.to/sudeep_c0d3s/binary-search-1-48hg</link>
      <guid>https://dev.to/sudeep_c0d3s/binary-search-1-48hg</guid>
      <description>&lt;p&gt;Key points -&lt;br&gt;
1) Search space - 0 to row*cols-1;&lt;br&gt;
   Reason - when directly divided by no of columns in a row &lt;br&gt;
   You get directly the row and col &lt;br&gt;
   Eg : 11 is mid and cols in a row is 4&lt;br&gt;
        11/4 -&amp;gt; 2nd row and 3 col in matrix &lt;br&gt;
        which is 12th ele -&amp;gt; 3rd row 4th ele&lt;br&gt;
2) Once row and col is derived from mid&lt;br&gt;
   Same binary search logic is applied&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 boolean searchMatrix(int[][] matrix, int target) {
        int rows = matrix.length;
        int cols = matrix[0].length;
        int low = 0;
        int high = rows * cols - 1;

        while (low &amp;lt;= high) {
            int mid = low + (high - low) / 2;
            int row = mid / cols;
            int col = mid % cols;

            if (matrix[row][col] == target) {
                return true;
            } else if (matrix[row][col] &amp;lt; target) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }

        return false;
    }
}

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

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Binary Search</title>
      <dc:creator>Sudeep .U</dc:creator>
      <pubDate>Thu, 26 Jun 2025 17:40:08 +0000</pubDate>
      <link>https://dev.to/sudeep_c0d3s/binary-search-2l67</link>
      <guid>https://dev.to/sudeep_c0d3s/binary-search-2l67</guid>
      <description>&lt;p&gt;Key points &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Calculate mid - int mid = low + (high - low) / 2;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;if mid is lesser than target increase low by 1 or else mid is greater than target then high decrease by 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the loop condition - low &amp;lt; = high &lt;br&gt;
take ex : 1,3,5,7,9 target =9 &lt;br&gt;
we have to track at point low == high so if its equal to target.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution {
    public int search(int[] nums, int target) {
        int low=0;
        int high = nums.length-1;
        while(low&amp;lt;high){
            int mid = (low+high)/2;
            if(nums[mid]==target) return mid;
            else if(nums[mid]&amp;lt;target){
                low=mid+1;
            }
            else{
                high=mid-1;
            }
        }
        return -1;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>howto</category>
      <category>codenewbie</category>
      <category>coding</category>
    </item>
    <item>
      <title>DSA</title>
      <dc:creator>Sudeep .U</dc:creator>
      <pubDate>Sat, 01 Feb 2025 19:11:41 +0000</pubDate>
      <link>https://dev.to/sudeep_c0d3s/dsa-2996</link>
      <guid>https://dev.to/sudeep_c0d3s/dsa-2996</guid>
      <description>&lt;p&gt;I am an amateur trying to debug and learn DSA.&lt;br&gt;
Lets analyse the problem and break it down so we find the pattern as a solution.&lt;br&gt;
Lets go !!!!&lt;/p&gt;

&lt;p&gt;Note : Following multiple sde sheets will share where the approach was taken from.&lt;/p&gt;

&lt;p&gt;Thank you&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>java</category>
      <category>challenge</category>
    </item>
  </channel>
</rss>
