<?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>Forem: Aayam Bhatt</title>
    <description>The latest articles on Forem by Aayam Bhatt (@aayambhatt).</description>
    <link>https://forem.com/aayambhatt</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%2F1822494%2Fa45b0042-67c7-47a1-929f-c69e1f6c3b9f.jpg</url>
      <title>Forem: Aayam Bhatt</title>
      <link>https://forem.com/aayambhatt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aayambhatt"/>
    <language>en</language>
    <item>
      <title>The Classic...Two Sum Problem</title>
      <dc:creator>Aayam Bhatt</dc:creator>
      <pubDate>Sun, 24 Aug 2025 17:56:12 +0000</pubDate>
      <link>https://forem.com/aayambhatt/the-classictwo-sum-problem-5fcp</link>
      <guid>https://forem.com/aayambhatt/the-classictwo-sum-problem-5fcp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Two Sum is the most classic problem, Leetcode # 1 problem &lt;br&gt;
It gives us an array of integers and an integer target, and asks us to return indices of two numbers such that they add to target&lt;br&gt;
Now this problem might seem easy but optimization is still something to think hard on. &lt;br&gt;
Before that, let's see it's brute force, that is, solving it without caring about efficiency and constraints. &lt;/p&gt;
&lt;h2&gt;
  
  
  Brute Force
&lt;/h2&gt;

&lt;p&gt;Brute force would be to check for every pair in array and see if they sum to target, if so, we will return their indices, if not, we'll return empty array&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 int[] twoSum(int[] nums, int target) {
        for (int i = 0; i &amp;lt; nums.length; i++) {
            for (int j = i + 1; j &amp;lt; nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[] { i, j };
                }
            }
        }
        return new int[] {}; // No solution found
    }
}

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

&lt;/div&gt;



&lt;p&gt;Basically let's say array given was {2,4,7,6} and target was 10&lt;br&gt;
Then we'd start with 2, and check its sum with remaining elements...&lt;br&gt;
&lt;code&gt;2+4&lt;/code&gt;, &lt;code&gt;2+7&lt;/code&gt;, &lt;code&gt;2+6&lt;/code&gt; and none of them sums to target value, so we move ahead, now 4, &lt;code&gt;4+7&lt;/code&gt;, &lt;code&gt;4+6&lt;/code&gt; HERE we have our answer...&lt;code&gt;4+6=10&lt;/code&gt;&lt;br&gt;
So we'll return [1,3]&lt;br&gt;
But it's time complexity is O(n^2) which is very slow if input is large. It's like we have some ingredients and we're checking every possible combination to see if our dish is tasty..works on small number but when there's thousand ingredients, it's very slow&lt;/p&gt;

&lt;p&gt;That's where the usage of &lt;strong&gt;Data Structure&lt;/strong&gt; comes in&lt;br&gt;
We will use HashMap to keep a compliment that will check if we've seen our partner..&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 int[] twoSum(int[] nums, int target) {
        HashMap&amp;lt;Integer, Integer&amp;gt; map = new HashMap&amp;lt;&amp;gt;();

        for(int i = 0 ; i&amp;lt;nums.length ; i++){
            int compliment = target - nums[i];

            if(map.containsKey(compliment)){
                return new int[] {map.get(compliment), i};
            }
            // Store the current number and its index
            map.put(nums[i], i);
        }
        return new int[] {}; 
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here TC = O(n) &lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
    </item>
    <item>
      <title>Making Python Act Like Bash</title>
      <dc:creator>Aayam Bhatt</dc:creator>
      <pubDate>Sun, 17 Aug 2025 17:08:08 +0000</pubDate>
      <link>https://forem.com/aayambhatt/making-python-act-like-bash-4m6n</link>
      <guid>https://forem.com/aayambhatt/making-python-act-like-bash-4m6n</guid>
      <description>&lt;p&gt;Python is a very powerful language, with just a couple of lines you can make Python behave like a mini bash shell. &lt;br&gt;
It sounded too good so I tried writing those couple of lines and result was a tiny program that lets you run commands like &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;pwd&lt;/code&gt; or anything else you'd normally run in terminal, all from inside Python.&lt;/p&gt;

&lt;p&gt;Full code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os

command = input("$ ")

while command != "exit":
    os.system(command)
    command = input("$ ")

print("Thank you, exiting!")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How it works?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python shows me a prompt ($ ) and waits for my input.&lt;/li&gt;
&lt;li&gt;If I type something like ls (on Linux/Mac) or dir (on Windows), it passes that command to os.system().&lt;/li&gt;
&lt;li&gt;Behind the scenes, os.system() calls a C function (system()), which then asks the shell (/bin/sh or cmd.exe) to run the command.&lt;/li&gt;
&lt;li&gt;The shell runs it, prints the output right in my terminal, and then Python asks me again for the next command.&lt;/li&gt;
&lt;li&gt;If I type exit, the loop stops and the script politely says “Thank you, exiting!”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the flow diagram: &lt;/p&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%2Fjb1z4kvudoeahgiqon8n.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%2Fjb1z4kvudoeahgiqon8n.png" alt="Flow Diagram" width="800" height="1277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So that was it, remember...running raw shell commands is a risky job as someone could just &lt;code&gt;rm -rf *&lt;/code&gt; deleting everything on your computer but it’s a nice way to peek under the hood at how Python talks to the operating system. &lt;/p&gt;

</description>
      <category>python</category>
      <category>bash</category>
      <category>shell</category>
      <category>programming</category>
    </item>
    <item>
      <title>Only Productivity Application you need ( It's Free )</title>
      <dc:creator>Aayam Bhatt</dc:creator>
      <pubDate>Thu, 19 Jun 2025 04:09:06 +0000</pubDate>
      <link>https://forem.com/aayambhatt/only-productivity-application-you-need-its-free--a5o</link>
      <guid>https://forem.com/aayambhatt/only-productivity-application-you-need-its-free--a5o</guid>
      <description>&lt;h2&gt;
  
  
  Super Productivity ( Yes that's the application and it's open source)
&lt;/h2&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%2Fqa6gdycdmuoh75d1wi74.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%2Fqa6gdycdmuoh75d1wi74.png" alt="Application Screenshot of Super Productivity" width="800" height="747"&gt;&lt;/a&gt; &lt;br&gt;
That's how the application looks like.&lt;br&gt;
If you’re someone who writes code and forgets what you were doing five minutes ago or gets confused on what to do next, struggles in managing tasks, tracking time and analyzing daily, weekly, monthly reports of work-productivity (me literally every day), you should check out &lt;strong&gt;Super Productivity&lt;/strong&gt;. It’s kind of like a to-do list app with time tracking, pomodoro, project management, tags, but way more useful and not obsessed with being all aesthetic while hiding half the features you actually need.&lt;/p&gt;

&lt;p&gt;You can make tasks, sort them into projects and even link your GitHub, Jira or gitlab so your issues just show up in the app. Super handy if you're working on a lots of repos or trying to manage freelance gigs and side projects without losing your mind. &lt;br&gt;
I personally use it for my personal work management and productivity, seeing a &lt;strong&gt;timer&lt;/strong&gt; running out with my &lt;strong&gt;task name&lt;/strong&gt; written and &lt;strong&gt;tags&lt;/strong&gt; ( &lt;em&gt;for better view of what you're working on and spending time on&lt;/em&gt; ) and it's been an amazing application.&lt;/p&gt;

&lt;p&gt;There’s also a built in time tracker, which is great for figuring out how much time you're actually coding vs. how much you’re just scrolling reels or watching “How to learn X in 10 minutes” videos that you’ll never use. The daily planning stuff lets you set your top goals and see what you got done, that's kind of satisfying, like really pushing to do more and achieve more&lt;/p&gt;

&lt;p&gt;It’s completely free and &lt;strong&gt;open source&lt;/strong&gt;. No logins, no ads, no “upgrade to unlock basic features” trap. Just download it and go yeehaww!&lt;/p&gt;

&lt;p&gt;If you’ve been jumping between ten different productivity apps and still feel all over the place, give this one a try. It’s simple but very powerful. You can tell it was made by someone who actually gets dev life aka &lt;a href="https://github.com/johannesjo" rel="noopener noreferrer"&gt;https://github.com/johannesjo&lt;/a&gt; ( creator of Super Productivity ) &lt;/p&gt;

</description>
      <category>programming</category>
      <category>management</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
