<?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: Shreyas R</title>
    <description>The latest articles on DEV Community by Shreyas R (@shreyas_r).</description>
    <link>https://dev.to/shreyas_r</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2983493%2Fc7016bf5-cca8-4fcb-89b1-760c17019821.png</url>
      <title>DEV Community: Shreyas R</title>
      <link>https://dev.to/shreyas_r</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shreyas_r"/>
    <language>en</language>
    <item>
      <title>"An alternative spiral matrix traversal using list.size() for dynamic termination, eliminating boundary variables:Innovative"</title>
      <dc:creator>Shreyas R</dc:creator>
      <pubDate>Thu, 27 Mar 2025 21:26:14 +0000</pubDate>
      <link>https://dev.to/shreyas_r/an-alternative-spiral-matrix-traversal-using-listsize-for-dynamic-termination-eliminating-29if</link>
      <guid>https://dev.to/shreyas_r/an-alternative-spiral-matrix-traversal-using-listsize-for-dynamic-termination-eliminating-29if</guid>
      <description>&lt;p&gt;class Solution {&lt;br&gt;
    public List spiralOrder(int[][] matrix) {&lt;br&gt;
        if (matrix == null || matrix.length == 0) return new ArrayList&amp;lt;&amp;gt;();&lt;br&gt;
        int m=matrix.length;&lt;br&gt;
        int n=matrix[0].length;&lt;br&gt;
        int totalelements=m*n;&lt;br&gt;
         List list = new ArrayList&amp;lt;&amp;gt;();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   for(int layer=0;layer &amp;lt;totalelements;layer++){
        int row=layer;
        int col=matrix[0].length-1-layer;
        for(int j=layer; list.size()&amp;lt;totalelements &amp;amp;&amp;amp; j&amp;lt;n-layer ;j++){
            list.add(matrix[row][j]);
        }
        for(int i=layer+1; list.size()&amp;lt;totalelements &amp;amp;&amp;amp; i&amp;lt;m-layer ;i++){
            list.add(matrix[i][col]);
        }
        row=matrix.length-1-layer;
         for(int j=n-2-layer;  list.size()&amp;lt;totalelements &amp;amp;&amp;amp;j&amp;gt;=layer  ;j--){
            list.add(matrix[row][j]);
        }

        col=layer;
        for(int i=m-2-layer;   list.size()&amp;lt;totalelements &amp;amp;&amp;amp; i&amp;gt;=layer+1 ;i--){
                list.add(matrix[i][col]);
        }


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

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
  </channel>
</rss>
