<?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: bala</title>
    <description>The latest articles on DEV Community by bala (@bala_kumaran).</description>
    <link>https://dev.to/bala_kumaran</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%2F1574757%2F65a168a8-fe80-4823-9cd7-dc5d46df481e.png</url>
      <title>DEV Community: bala</title>
      <link>https://dev.to/bala_kumaran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bala_kumaran"/>
    <language>en</language>
    <item>
      <title>Leetcode 547 solving with intuition - 6/8/26</title>
      <dc:creator>bala</dc:creator>
      <pubDate>Mon, 08 Jun 2026 15:17:33 +0000</pubDate>
      <link>https://dev.to/bala_kumaran/leetcode-547-solving-with-intuition-6826-529m</link>
      <guid>https://dev.to/bala_kumaran/leetcode-547-solving-with-intuition-6826-529m</guid>
      <description>&lt;h3&gt;
  
  
  Q1) 547. Number of Provinces
&lt;/h3&gt;

&lt;p&gt;👉 &lt;a href="https://leetcode.com/problems/number-of-provinces" rel="noopener noreferrer"&gt;LeetCode Problem Link&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  💡 Initial Idea &amp;amp; The Mistake
&lt;/h4&gt;

&lt;p&gt;My first instinct was to simply count the rows where the array sum equals 1 (meaning a city is only connected to itself), assuming everything else would naturally hook together into a single province. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The flaw in that logic:&lt;/strong&gt; I completely overlooked scenarios where you might have multiple distinct, disconnected clusters of cities (e.g., two cities connected to each other, while three other cities form their own separate group). &lt;/p&gt;

&lt;p&gt;To fix this, I broke out a notepad, sketched out the graph visually, and realized this was a classic graph traversal problem perfectly suited for &lt;strong&gt;Depth-First Search (DFS)&lt;/strong&gt;.&lt;/p&gt;




&lt;h4&gt;
  
  
  🛠️ Optimized DFS Solution (Java)
&lt;/h4&gt;

&lt;p&gt;In my initial draft, I used an external helper function (&lt;code&gt;allVisit&lt;/code&gt;) to scan the visited array repeatedly inside a loop. This added unnecessary overhead. By simply looping through all cities once from &lt;code&gt;0 to n-1&lt;/code&gt; and triggering a DFS whenever we hit an unvisited city, we can count the provinces much more efficiently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;findCircleNum&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;[][]&lt;/span&gt; &lt;span class="n"&gt;isConnected&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;cities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;isConnected&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;provinces&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cities&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;

        &lt;span class="c1"&gt;// Loop through each city. If it hasn't been visited, &lt;/span&gt;
        &lt;span class="c1"&gt;// it represents the start of a new province.&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;cities&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;dfs&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;isConnected&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;provinces&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt; &lt;span class="c1"&gt;// Increment the province count&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;provinces&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;dfs&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;[][]&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Visit all adjacent, unvisited cities&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="o"&gt;][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;])&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;dfs&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visited&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jzluqak5x6vwi6cu3cd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jzluqak5x6vwi6cu3cd.png" alt="openboard drawing of graph" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode547</category>
    </item>
    <item>
      <title>I'm Starting Over — And That Might Be My Biggest Advantage</title>
      <dc:creator>bala</dc:creator>
      <pubDate>Sat, 06 Jun 2026 13:47:08 +0000</pubDate>
      <link>https://dev.to/bala_kumaran/im-starting-over-and-that-might-be-my-biggest-advantage-18og</link>
      <guid>https://dev.to/bala_kumaran/im-starting-over-and-that-might-be-my-biggest-advantage-18og</guid>
      <description>&lt;p&gt;Yesterday, I finished my 6th semester examinations.&lt;/p&gt;

&lt;p&gt;For most students, that's the end of a stressful academic phase. For me, it's the start of something more demanding — placement season.&lt;/p&gt;

&lt;p&gt;Here's a realization I've been sitting with:&lt;/p&gt;

&lt;p&gt;Most people think placement success comes from knowing more. I think it comes from being willing to start over.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Comfortable Trap&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;I've spent the last few years building projects, solving problems, exploring AI, and competing in hackathons. My DSA skills are solid — not exceptional, but not weak either.&lt;/p&gt;

&lt;p&gt;The dangerous thing about being "decent" is that it's easy to stop questioning yourself. You rely on old knowledge, old approaches, old confidence.&lt;/p&gt;

&lt;p&gt;Placement prep forced me to confront an uncomfortable truth: what got me here may not be enough to get me where I want to go.&lt;/p&gt;

&lt;p&gt;So instead of defending what I already know, I'm choosing to play the game again — this time with experience.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Context Nobody Talks About&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;I'm from Electrical and Electronics Engineering, not Computer Science. I don't have a curriculum built around software engineering, OS, databases, or networking.&lt;/p&gt;

&lt;p&gt;That's fine.&lt;/p&gt;

&lt;p&gt;Being outside the traditional path taught me something: when you don't have the roadmap, you learn to build one. Every project, every debugging session, every late night has shown me that progress is rarely about ideal circumstances — it's about consistency despite imperfect ones.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Plan&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For the next few months, I'm committing to six areas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DSA&lt;/strong&gt; — Pattern recognition and problem-solving under pressure, not just volume&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Projects&lt;/strong&gt; — Building things that strengthen engineering thinking, not just resume lines&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Aptitude&lt;/strong&gt; — Consistent practice over last-minute cramming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communication&lt;/strong&gt; — Explaining ideas clearly is as critical as understanding them&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Building in public&lt;/strong&gt; — Accountability creates momentum; feedback creates improvement&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Networking&lt;/strong&gt; — Opportunities find people who position themselves well&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Real Goal&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Not perfection across any of these. Just Kaizen — 1% better every day.&lt;/p&gt;

&lt;p&gt;The person who walks into interviews a few months from now won't be the same person who finished his exams yesterday. That's the point.&lt;/p&gt;

</description>
      <category>career</category>
      <category>devjournal</category>
      <category>interview</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
