<?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: Pradum Saindane</title>
    <description>The latest articles on DEV Community by Pradum Saindane (@pradumnscode).</description>
    <link>https://dev.to/pradumnscode</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%2F2174073%2Ff66389f6-244d-4a35-b1b5-892d5483a961.jpg</url>
      <title>DEV Community: Pradum Saindane</title>
      <link>https://dev.to/pradumnscode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pradumnscode"/>
    <language>en</language>
    <item>
      <title>🚀 Longest Balanced Subarray (Distinct Even = Distinct Odd)</title>
      <dc:creator>Pradum Saindane</dc:creator>
      <pubDate>Tue, 10 Feb 2026 16:59:44 +0000</pubDate>
      <link>https://dev.to/pradumnscode/longest-balanced-subarray-distinct-even-distinct-odd-4oh4</link>
      <guid>https://dev.to/pradumnscode/longest-balanced-subarray-distinct-even-distinct-odd-4oh4</guid>
      <description>&lt;p&gt;Recently, I worked on an interesting array problem:&lt;/p&gt;

&lt;p&gt;A subarray is called balanced if the number of distinct even numbers is equal to the number of distinct odd numbers. The task is to return the length of the longest such subarray.&lt;/p&gt;

&lt;p&gt;At first glance, this looks like a simple parity count problem. Naturally, thoughts go toward prefix sums or sliding window techniques. But the real challenge lies in one word  distinct.&lt;/p&gt;

&lt;p&gt;We are not counting how many even or odd elements exist. We are counting how many unique even and unique odd values exist inside a subarray. That changes the entire strategy.&lt;/p&gt;

&lt;p&gt;Distinct counts are not monotonic. If we shrink a window, removing one element might reduce the distinct count or it might not. That makes classic two pointer shrinking approaches unreliable here.&lt;/p&gt;

&lt;p&gt;Given the constraint (n ≤ 1500), an O(n²) solution is fully acceptable and optimal.&lt;/p&gt;

&lt;p&gt;💡 Approach&lt;/p&gt;

&lt;p&gt;For every starting index:&lt;br&gt;
    • Expand the subarray to the right.&lt;br&gt;
    • Maintain a frequency map.&lt;br&gt;
    • Track two counters:&lt;br&gt;
    • evenDistinct&lt;br&gt;
    • oddDistinct&lt;br&gt;
    • Whenever both are equal, update the maximum length.&lt;/p&gt;

&lt;p&gt;This guarantees correctness while staying within acceptable time complexity.&lt;/p&gt;

&lt;p&gt;✅ Java Implementation&lt;br&gt;
import java.util.*;&lt;/p&gt;

&lt;p&gt;class Solution {&lt;br&gt;
    public int longestBalanced(int[] nums) {&lt;br&gt;
        int n = nums.length;&lt;br&gt;
        int maxLen = 0;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    for (int i = 0; i &amp;lt; n; i++) {
        Map&amp;lt;Integer, Integer&amp;gt; freq = new HashMap&amp;lt;&amp;gt;();
        int evenDistinct = 0;
        int oddDistinct = 0;

        for (int j = i; j &amp;lt; n; j++) {
            int num = nums[j];

            if (!freq.containsKey(num)) {
                freq.put(num, 1);
                if (num % 2 == 0) evenDistinct++;
                else oddDistinct++;
            } else {
                freq.put(num, freq.get(num) + 1);
            }

            if (evenDistinct == oddDistinct) {
                maxLen = Math.max(maxLen, j - i + 1);
            }
        }
    }

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

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
📊 Complexity&lt;br&gt;
    • Time Complexity: O(n²)&lt;br&gt;
    • Space Complexity: O(n)&lt;/p&gt;

&lt;p&gt;🎯 My POV&lt;/p&gt;

&lt;p&gt;This problem reminded me that not every array problem fits into the “optimize to O(n)” mindset. Sometimes, understanding constraints and choosing the correct strategy is more important than forcing a pattern.&lt;/p&gt;

&lt;p&gt;The biggest lesson:&lt;br&gt;
When you see words like distinct or unique, pause before applying sliding window blindly.&lt;/p&gt;

&lt;p&gt;Strong problem-solving is not about memorising patterns  it’s about recognising when patterns don’t apply.&lt;/p&gt;

&lt;p&gt;That’s where real growth happens as a developer.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>coding</category>
      <category>computerscience</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>HELLO WORLD</title>
      <dc:creator>Pradum Saindane</dc:creator>
      <pubDate>Tue, 30 Dec 2025 08:58:29 +0000</pubDate>
      <link>https://dev.to/pradumnscode/hello-world-293a</link>
      <guid>https://dev.to/pradumnscode/hello-world-293a</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I’m excited to publish my first post on dev.to and become part of this amazing developer community.&lt;/p&gt;

&lt;p&gt;I have completed my Full-Stack Web Development journey and gained hands-on, industry-level experience in building end-to-end applications. My learning includes Java, Flutter, and modern web technologies, with a strong focus on writing clean, scalable, and maintainable code.&lt;/p&gt;

&lt;p&gt;I created this dev.to profile to:&lt;br&gt;
        • Document my learning and projects&lt;br&gt;
    • Share practical development insights&lt;br&gt;
    • Improve through community feedback&lt;br&gt;
    • Prepare myself for professional software development roles&lt;/p&gt;

&lt;p&gt;Going forward, I’ll be posting about:&lt;br&gt;
    • Full-stack concepts and real-world implementations&lt;br&gt;
    • Java and backend development topics&lt;br&gt;
    • Flutter and cross-platform app development&lt;br&gt;
    • Lessons learned from projects and problem-solving&lt;/p&gt;

&lt;p&gt;I believe consistency, fundamentals, and community learning are key to long-term growth in tech. Looking forward to learning, sharing, and growing together.&lt;/p&gt;

&lt;p&gt;Thank you for reading.&lt;/p&gt;

</description>
      <category>career</category>
      <category>learning</category>
      <category>community</category>
      <category>devto</category>
    </item>
  </channel>
</rss>
