<?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: hassam bin shahid </title>
    <description>The latest articles on DEV Community by hassam bin shahid  (@hassam645).</description>
    <link>https://dev.to/hassam645</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%2F3967820%2Fa2fd1cf8-c8d6-4a06-905e-1c57c44d347d.jpeg</url>
      <title>DEV Community: hassam bin shahid </title>
      <link>https://dev.to/hassam645</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassam645"/>
    <language>en</language>
    <item>
      <title>🚀 DSA Progress Update | Solved 3 LeetCode Problems</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Mon, 20 Jul 2026 16:08:44 +0000</pubDate>
      <link>https://dev.to/hassam645/dsa-progress-update-solved-3-leetcode-problems-4i6n</link>
      <guid>https://dev.to/hassam645/dsa-progress-update-solved-3-leetcode-problems-4i6n</guid>
      <description>&lt;p&gt;🚀 &lt;strong&gt;DSA Progress Update | Solved 3 LeetCode Problems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today's LeetCode session was focused on strengthening my understanding of three fundamental problem-solving patterns that frequently appear in technical interviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Problems Solved
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;🔹 682. Baseball Game&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; Stack&lt;/li&gt;
&lt;li&gt;Built a score history using a stack to efficiently process operations such as &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;D&lt;/code&gt;, and &lt;code&gt;C&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(n)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;operations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;D&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;C&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🔹 1456. Maximum Number of Vowels in a Substring of Given Length&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; Sliding Window&lt;/li&gt;
&lt;li&gt;Optimized the brute-force approach by maintaining a fixed-size window and updating the vowel count in constant time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(n)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;vowels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;e&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;o&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;u&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vowels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;maximum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&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;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vowels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vowels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;maximum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;maximum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;maximum&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;🔹 134. Gas Station&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; Greedy Algorithm&lt;/li&gt;
&lt;li&gt;Learned how tracking the fuel balance helps identify the only valid starting station while solving the problem in linear time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(n)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="n"&gt;tank&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gas&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;tank&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;gas&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tank&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;start&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="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;tank&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  💡 Key Takeaways
&lt;/h3&gt;

&lt;p&gt;✔️ Choosing the right algorithmic pattern is often more important than writing more code.&lt;/p&gt;

&lt;p&gt;✔️ Today's practice reinforced three essential interview concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stack&lt;/li&gt;
&lt;li&gt;Sliding Window&lt;/li&gt;
&lt;li&gt;Greedy Algorithm&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every problem I solve improves not only my coding skills but also my ability to analyze problems, optimize solutions, and think like a software engineer.&lt;/p&gt;

&lt;p&gt;I'm committed to solving LeetCode problems consistently and documenting my progress as I continue growing in Data Structures &amp;amp; Algorithms.&lt;/p&gt;

&lt;h1&gt;
  
  
  LeetCode #Python #DSA #Algorithms #ProblemSolving #SoftwareEngineering #CodingJourney #100DaysOfCode #Tech #Developer #LearningInPublic
&lt;/h1&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>devjournal</category>
      <category>python</category>
    </item>
    <item>
      <title>🚀 DSA Journey | Solved 3 LeetCode Problems in Python</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Sat, 18 Jul 2026 18:21:24 +0000</pubDate>
      <link>https://dev.to/hassam645/dsa-journey-solved-3-leetcode-problems-in-python-47bm</link>
      <guid>https://dev.to/hassam645/dsa-journey-solved-3-leetcode-problems-in-python-47bm</guid>
      <description>&lt;p&gt;Today's practice focused on three different algorithmic patterns, each reinforcing an important concept in problem solving and writing efficient code.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ 1. To Lower Case (LeetCode 709)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; String Manipulation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Takeaway:&lt;/strong&gt; Reviewed string operations and learned how character conversion can also be implemented using ASCII values.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ 2. Product of Array Except Self (LeetCode 238)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Prefix &amp;amp; Suffix Products&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;productExceptSelf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;

        &lt;span class="n"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;ans&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prefix&lt;/span&gt;
            &lt;span class="n"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="n"&gt;suffix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;ans&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;suffix&lt;/span&gt;
            &lt;span class="n"&gt;suffix&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ans&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Takeaway:&lt;/strong&gt; Practiced solving array problems in &lt;strong&gt;O(n)&lt;/strong&gt; time without using division by leveraging prefix and suffix products.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ 3. Maximum Average Subarray I (LeetCode 643)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Sliding Window&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;findMaxAverage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;window_sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="n"&gt;max_sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;window_sum&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="n"&gt;window_sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&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;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;max_sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;window_sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;max_sum&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Takeaway:&lt;/strong&gt; Applied the Sliding Window technique to optimize repeated calculations and reduce the time complexity to &lt;strong&gt;O(n)&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;Every LeetCode problem teaches more than just syntax—it strengthens analytical thinking, algorithm selection, and code optimization. Consistency in practice is helping me build a stronger foundation in Data Structures and Algorithms, one problem at a time.&lt;/p&gt;

&lt;p&gt;I'm looking forward to tackling more challenging problems and continuing to grow as a software engineer.&lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;Language:&lt;/strong&gt; Python&lt;br&gt;
📚 &lt;strong&gt;Topics Covered:&lt;/strong&gt; String Manipulation, Prefix &amp;amp; Suffix Products, Sliding Window&lt;/p&gt;

&lt;h1&gt;
  
  
  LeetCode #Python #DSA #Algorithms #ProblemSolving #SoftwareEngineering #CodingJourney #100DaysOfCode #Developer #Programming
&lt;/h1&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>python</category>
    </item>
    <item>
      <title># 🚀 Solving 3 LeetCode Problems in Python: String Manipulation, Hashing, and Data Structures</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Mon, 13 Jul 2026 18:41:30 +0000</pubDate>
      <link>https://dev.to/hassam645/-solving-3-leetcode-problems-in-python-string-manipulation-hashing-and-data-structures-1e3</link>
      <guid>https://dev.to/hassam645/-solving-3-leetcode-problems-in-python-string-manipulation-hashing-and-data-structures-1e3</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Solving 3 LeetCode Problems in Python: String Manipulation, Hashing, and Data Structures
&lt;/h1&gt;

&lt;p&gt;Consistency is the key to becoming a better software engineer. As part of my daily Data Structures and Algorithms (DSA) practice, I solved three LeetCode problems that strengthened my understanding of string manipulation, hash maps, and designing efficient data structures.&lt;/p&gt;

&lt;h2&gt;
  
  
  📌 Problems Solved Today
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ Length of Last Word (LeetCode #58)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given a string consisting of words and spaces, return the length of the last word.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;br&gt;
I removed any trailing spaces using &lt;code&gt;strip()&lt;/code&gt;, split the string into words, and returned the length of the last word.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Solution&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;lengthOfLastWord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(n)&lt;br&gt;
&lt;strong&gt;Space Complexity:&lt;/strong&gt; O(n)&lt;/p&gt;


&lt;h3&gt;
  
  
  2️⃣ Max Number of K-Sum Pairs (LeetCode #1679)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an integer array &lt;code&gt;nums&lt;/code&gt; and an integer &lt;code&gt;k&lt;/code&gt;, return the maximum number of operations where each operation removes two numbers whose sum equals &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;br&gt;
I used a Hash Map (dictionary) to keep track of previously seen numbers. For every element, I searched for its complement (&lt;code&gt;k - num&lt;/code&gt;). If found, I formed a valid pair; otherwise, I stored the current number for future matching.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Solution&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;defaultdict&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;maxOperations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;operations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;complement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;complement&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;operations&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;complement&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;operations&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(n)&lt;br&gt;
&lt;strong&gt;Space Complexity:&lt;/strong&gt; O(n)&lt;/p&gt;


&lt;h3&gt;
  
  
  3️⃣ Insert Delete GetRandom O(1) (LeetCode #380)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Design a data structure that supports insertion, deletion, and returning a random element in average &lt;strong&gt;O(1)&lt;/strong&gt; time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;br&gt;
The optimal solution combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;list&lt;/strong&gt; for storing elements.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;hash map&lt;/strong&gt; to store the index of each element.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This combination enables constant-time insertion, deletion (by swapping with the last element), and random access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Solution&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RandomizedSet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

        &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;

        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;getRandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Time Complexity&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Insert: O(1)&lt;/li&gt;
&lt;li&gt;Remove: O(1)&lt;/li&gt;
&lt;li&gt;GetRandom: O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity:&lt;/strong&gt; O(n)&lt;/p&gt;




&lt;h1&gt;
  
  
  💡 Key Takeaways
&lt;/h1&gt;

&lt;p&gt;✔️ Improved string manipulation techniques.&lt;br&gt;
✔️ Strengthened understanding of Hash Maps for efficient lookups.&lt;br&gt;
✔️ Learned how combining arrays and hash maps enables constant-time operations.&lt;br&gt;
✔️ Reinforced the importance of choosing the right data structure for optimized solutions.&lt;/p&gt;

&lt;p&gt;Every LeetCode problem is an opportunity to think critically, write cleaner code, and improve algorithmic problem-solving skills. Small, consistent improvements today lead to significant growth tomorrow.&lt;/p&gt;

&lt;p&gt;If you're also practicing DSA, I'd love to connect and discuss different approaches to solving problems. Happy coding! 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  LeetCode #DSA #Python #Algorithms #DataStructures #ProblemSolving #SoftwareEngineering #Coding #Programming #TechCommunity #100DaysOfCode #DeveloperJourney
&lt;/h1&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>python</category>
    </item>
    <item>
      <title>🚀 DSA Journey Update | Solved 3 LeetCode Problems in Python</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Sat, 11 Jul 2026 10:11:35 +0000</pubDate>
      <link>https://dev.to/hassam645/dsa-journey-update-solved-3-leetcode-problems-in-python-3l7a</link>
      <guid>https://dev.to/hassam645/dsa-journey-update-solved-3-leetcode-problems-in-python-3l7a</guid>
      <description>&lt;p&gt;Continuing my journey of improving problem-solving skills and strengthening my Data Structures &amp;amp; Algorithms fundamentals.&lt;/p&gt;

&lt;p&gt;Today, I solved three important LeetCode problems that helped me practice different algorithmic techniques:&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Roman to Integer (LeetCode #13)&lt;/strong&gt;&lt;br&gt;
🔹 Learned how to handle symbol mapping and subtraction patterns using Hash Maps.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Container With Most Water (LeetCode #11)&lt;/strong&gt;&lt;br&gt;
🔹 Improved my understanding of the Two Pointer technique to achieve an optimized O(n) solution.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;H-Index (LeetCode #274)&lt;/strong&gt;&lt;br&gt;
🔹 Practiced sorting-based problem solving and learned how to analyze citation-based conditions efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways:
&lt;/h3&gt;

&lt;p&gt;✔️ Choosing the right algorithm can significantly improve performance.&lt;br&gt;
✔️ Understanding patterns like Two Pointers and Sorting helps solve complex problems faster.&lt;br&gt;
✔️ Consistent practice builds strong problem-solving skills.&lt;/p&gt;

&lt;p&gt;Every problem solved is another step toward becoming a better software engineer. 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  LeetCode #DSA #Python #Algorithms #DataStructures #SoftwareEngineering #CodingJourney #100DaysOfCode
&lt;/h1&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>learning</category>
      <category>python</category>
    </item>
    <item>
      <title>🚀 Solving 3 LeetCode Problems: Arrays, Strings, and Greedy Algorithms</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Thu, 09 Jul 2026 19:02:07 +0000</pubDate>
      <link>https://dev.to/hassam645/solving-3-leetcode-problems-arrays-strings-and-greedy-algorithms-3c64</link>
      <guid>https://dev.to/hassam645/solving-3-leetcode-problems-arrays-strings-and-greedy-algorithms-3c64</guid>
      <description>&lt;p&gt;As part of my daily &lt;strong&gt;Data Structures and Algorithms (DSA)&lt;/strong&gt; practice, today I focused on solving three LeetCode problems that strengthened my understanding of &lt;strong&gt;arrays, string manipulation, and greedy algorithms&lt;/strong&gt;.&lt;br&gt;
Consistent practice is helping me improve my problem-solving skills and prepare for coding interviews.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Problems Solved
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Monotonic Array (LeetCode 896)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Arrays&lt;/p&gt;

&lt;p&gt;The goal was to determine whether an array is entirely non-decreasing or non-increasing.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How to identify increasing and decreasing trends in a single traversal.&lt;/li&gt;
&lt;li&gt;Why checking both possibilities simultaneously leads to an efficient solution.&lt;/li&gt;
&lt;li&gt;Time Complexity: &lt;strong&gt;O(n)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Space Complexity: &lt;strong&gt;O(1)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. String Compression (LeetCode 443)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Two Pointers, Strings&lt;/p&gt;

&lt;p&gt;This problem required compressing a character array in-place without using extra memory.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Applying the Two Pointers technique for reading and writing.&lt;/li&gt;
&lt;li&gt;Performing in-place modifications efficiently.&lt;/li&gt;
&lt;li&gt;Handling multi-digit counts correctly during compression.&lt;/li&gt;
&lt;li&gt;Time Complexity: &lt;strong&gt;O(n)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Space Complexity: &lt;strong&gt;O(1)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3. Jump Game II (LeetCode 45)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Concept:&lt;/strong&gt; Greedy Algorithm&lt;/p&gt;

&lt;p&gt;The challenge was to find the minimum number of jumps needed to reach the last index.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Learned
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How greedy algorithms can produce optimal solutions.&lt;/li&gt;
&lt;li&gt;Tracking the farthest reachable position while minimizing jumps.&lt;/li&gt;
&lt;li&gt;Understanding why greedy outperforms brute-force approaches for this problem.&lt;/li&gt;
&lt;li&gt;Time Complexity: &lt;strong&gt;O(n)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Space Complexity: &lt;strong&gt;O(1)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Key Takeaways
&lt;/h2&gt;

&lt;p&gt;Today's practice reinforced several important concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Efficient array traversal techniques.&lt;/li&gt;
&lt;li&gt;In-place string manipulation using Two Pointers.&lt;/li&gt;
&lt;li&gt;Solving optimization problems with Greedy Algorithms.&lt;/li&gt;
&lt;li&gt;Writing clean, optimized Python code with linear time complexity whenever possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more problems I solve, the better I become at recognizing patterns and selecting the right algorithmic approach.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Next Goal
&lt;/h2&gt;

&lt;p&gt;I'm committed to solving LeetCode problems every day to strengthen my fundamentals in Data Structures &amp;amp; Algorithms and become a better software engineer.&lt;/p&gt;

&lt;p&gt;If you're also practicing DSA, I'd love to hear about your favorite problem-solving strategies or discuss different approaches in the comments.&lt;/p&gt;

&lt;p&gt;Happy Coding! 🚀&lt;/p&gt;




&lt;h3&gt;
  
  
  🏷️ Tags
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;#leetcode&lt;/code&gt; &lt;code&gt;#python&lt;/code&gt; &lt;code&gt;#algorithms&lt;/code&gt; &lt;code&gt;#datastructures&lt;/code&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>interview</category>
      <category>learning</category>
    </item>
    <item>
      <title>🚀 My Daily DSA Practice – Solving 6 LeetCode Problems (Greedy + Arrays)</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Mon, 06 Jul 2026 18:09:03 +0000</pubDate>
      <link>https://dev.to/hassam645/my-daily-dsa-practice-solving-6-leetcode-problems-greedy-arrays-1jll</link>
      <guid>https://dev.to/hassam645/my-daily-dsa-practice-solving-6-leetcode-problems-greedy-arrays-1jll</guid>
      <description>&lt;p&gt;📌 Introduction&lt;/p&gt;

&lt;p&gt;Today I focused on strengthening my understanding of Greedy Algorithms and Array-based problems by solving multiple LeetCode questions.&lt;/p&gt;

&lt;p&gt;This practice helped me improve my pattern recognition, problem-solving speed, and coding efficiency in Python.&lt;/p&gt;

&lt;p&gt;🧠 Problems Solved&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign of the Product of an Array&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of calculating full multiplication, we only track:&lt;/p&gt;

&lt;p&gt;Number of negative values&lt;br&gt;
Presence of zero&lt;/p&gt;

&lt;p&gt;👉 Key idea:&lt;/p&gt;

&lt;p&gt;Even negatives → 1&lt;br&gt;
Odd negatives → -1&lt;br&gt;
Zero → 0&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is Subsequence&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Used Two Pointers Technique:&lt;/p&gt;

&lt;p&gt;Traverse both strings&lt;br&gt;
Match characters in order&lt;/p&gt;

&lt;p&gt;👉 Time Complexity: O(n)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Best Time to Buy and Sell Stock II&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Used Greedy Approach:&lt;/p&gt;

&lt;p&gt;Add every positive difference&lt;/p&gt;

&lt;p&gt;👉 Idea: Profit comes from every upward trend.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Can Make Arithmetic Progression
Sort array
Check constant difference between elements&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👉 Time Complexity: O(n log n)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Increasing Triplet Subsequence&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Used greedy tracking:&lt;/p&gt;

&lt;p&gt;first smallest&lt;br&gt;
second smallest larger than first&lt;/p&gt;

&lt;p&gt;👉 If third number found → return True&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Jump Game&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Track maximum reachable index:&lt;/p&gt;

&lt;p&gt;If index &amp;gt; max reach → return False&lt;br&gt;
💡 Key Learnings&lt;br&gt;
Greedy algorithms simplify complex problems using local optimal choices.&lt;br&gt;
Two pointers help reduce nested loops to linear time.&lt;br&gt;
Tracking variables (min, max, bounds) is often enough instead of brute force.&lt;br&gt;
Pattern recognition is the most important skill in DSA.&lt;br&gt;
⚡ Skills Improved Today&lt;br&gt;
Greedy Algorithms&lt;br&gt;
Two Pointers Technique&lt;br&gt;
Array Manipulation&lt;br&gt;
Time Complexity Optimization&lt;br&gt;
Python Problem Solving&lt;br&gt;
🚀 Conclusion&lt;/p&gt;

&lt;p&gt;Consistency is the key in mastering DSA. Each problem improves my ability to think logically and recognize patterns faster.&lt;/p&gt;

&lt;p&gt;I will continue solving problems daily and sharing my learning journey.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>leetcode</category>
      <category>python</category>
    </item>
    <item>
      <title>🚀 DSA Journey – Daily Learning Update</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Fri, 03 Jul 2026 17:21:23 +0000</pubDate>
      <link>https://dev.to/hassam645/dsa-journey-daily-learning-update-444m</link>
      <guid>https://dev.to/hassam645/dsa-journey-daily-learning-update-444m</guid>
      <description>&lt;p&gt;🚀 &lt;strong&gt;DSA Journey – Daily Learning Update&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today's learning session focused on strengthening my understanding of &lt;strong&gt;Arrays, Two Pointers, and Greedy Algorithms&lt;/strong&gt; by solving three LeetCode problems in Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Problems Solved
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sign of the Product of an Array&lt;/strong&gt; – Learned how to determine the sign of a product without computing the entire multiplication by tracking zeros and negative numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is Subsequence&lt;/strong&gt; – Practiced the &lt;strong&gt;Two Pointers&lt;/strong&gt; technique to efficiently verify whether one string is a subsequence of another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best Time to Buy and Sell Stock II&lt;/strong&gt; – Applied a &lt;strong&gt;Greedy Algorithm&lt;/strong&gt; to maximize profit by capturing every positive price difference.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  💡 Key Takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Strengthened problem-solving skills through pattern recognition.&lt;/li&gt;
&lt;li&gt;Improved understanding of &lt;strong&gt;Greedy Algorithms&lt;/strong&gt; and &lt;strong&gt;Two Pointers&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Practiced writing optimized Python solutions with efficient time and space complexity.&lt;/li&gt;
&lt;li&gt;Continued building consistency in my daily Data Structures &amp;amp; Algorithms journey.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every problem solved is another step toward becoming a better software engineer. Consistency, discipline, and continuous learning remain my biggest priorities.&lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;Today's LeetCode Progress&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Sign of the Product of an Array&lt;/li&gt;
&lt;li&gt;✅ Is Subsequence&lt;/li&gt;
&lt;li&gt;✅ Best Time to Buy and Sell Stock II&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🐍 &lt;strong&gt;Language:&lt;/strong&gt; Python&lt;/p&gt;

&lt;h1&gt;
  
  
  LeetCode #DSA #Python #Algorithms #GreedyAlgorithm #TwoPointers #Arrays #ProblemSolving #SoftwareEngineering #CodingJourney #LearningInPublic #TechJourney #ComputerScience #OpenToWork
&lt;/h1&gt;

</description>
      <category>algorithms</category>
      <category>devjournal</category>
      <category>leetcode</category>
      <category>python</category>
    </item>
    <item>
      <title>My First Step into LeetCode and Problem Solving Journey</title>
      <dc:creator>hassam bin shahid </dc:creator>
      <pubDate>Wed, 17 Jun 2026 17:56:51 +0000</pubDate>
      <link>https://dev.to/hassam645/my-first-step-into-leetcode-and-problem-solving-journey-4pi5</link>
      <guid>https://dev.to/hassam645/my-first-step-into-leetcode-and-problem-solving-journey-4pi5</guid>
      <description>&lt;p&gt;As a BSIT student passionate about Software Engineering, Data Structures &amp;amp; Algorithms, and Machine Learning, I have recently begun a consistent problem-solving journey on LeetCode. This is my first step toward improving my coding skills and strengthening my logical thinking.&lt;br&gt;
One of the first problems I worked on was “Merge Strings Alternately”. At first, it looked simple, but it helped me understand how important it is to break problems into smaller steps and think clearly about edge cases.&lt;br&gt;
Through this problem, I learned how to:&lt;br&gt;
Traverse two strings simultaneously&lt;br&gt;
Handle different lengths of input&lt;br&gt;
Build a new string step by step&lt;br&gt;
Improve my coding efficiency in Python&lt;br&gt;
Here is a simple approach I used:&lt;br&gt;
Use two pointers for both strings&lt;br&gt;
Alternate characters from each string&lt;br&gt;
Append remaining characters when one string ends&lt;br&gt;
This small problem gave me confidence that consistent practice is the key to improving in DSA.&lt;br&gt;
Key Takeaways&lt;br&gt;
Start with small problems and build consistency&lt;br&gt;
Focus on logic, not just syntax&lt;br&gt;
Practice improves speed and confidence&lt;br&gt;
Every problem teaches something new&lt;br&gt;
This is just the beginning of my journey. I will continue solving problems, learning new concepts, and sharing my progress here on Medium.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>leetcode</category>
      <category>python</category>
    </item>
  </channel>
</rss>
