<?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: snikmas</title>
    <description>The latest articles on Forem by snikmas (@snikmas).</description>
    <link>https://forem.com/snikmas</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%2F2800434%2Ffff1b706-8878-49db-b19a-e079f6583542.jpg</url>
      <title>Forem: snikmas</title>
      <link>https://forem.com/snikmas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/snikmas"/>
    <language>en</language>
    <item>
      <title>AI for a month: impressions, mistakes, and what actually worked</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Fri, 20 Mar 2026 06:58:14 +0000</pubDate>
      <link>https://forem.com/snikmas/ai-for-a-month-impressions-mistakes-and-what-actually-worked-5fji</link>
      <guid>https://forem.com/snikmas/ai-for-a-month-impressions-mistakes-and-what-actually-worked-5fji</guid>
      <description>&lt;p&gt;Two months ago I wrote a post where I was confused: where is the line between programming and using AI for it? What was I supposed to do on my own, and what could I delegate to AI? I felt like if I didn't start using AI right now, I'd miss the train.&lt;/p&gt;

&lt;p&gt;During this month I've been doing a lot of stuff with AI — and I'm really enjoying it. I figured out a few patterns: which ways of using AI &lt;strong&gt;bore me&lt;/strong&gt;, which ways I &lt;strong&gt;shouldn't&lt;/strong&gt; use it, and how I can actually use AI to &lt;strong&gt;learn&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Takeaway 1: I don't like when AI does everything for me
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I don't like the feeling of not understanding what's going on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There were times when I was tired of a project or just annoyed, and I'd say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I don't care how you do it, just do it."&lt;/p&gt;
&lt;/blockquote&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%2Fj31vn66337smpo61kbij.gif" 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%2Fj31vn66337smpo61kbij.gif" alt="DO IT" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI can do the work pretty well (in my case it was basics, so there usually weren't many problems). All I had to do was check the result, click buttons, and so on. If I spotted a bug — I'd tell it to fix that too.&lt;/p&gt;

&lt;p&gt;But looking back, &lt;strong&gt;I don't like that process.&lt;/strong&gt; It can give you a lot of code you don't understand. Some people are okay with that. Not me. I still want to understand as much as I can.&lt;/p&gt;




&lt;h2&gt;
  
  
  Takeaway 2: AI is not a programmer — it's a guide, teacher, and product manager
&lt;/h2&gt;

&lt;p&gt;Before, when I wanted to build something and didn't know how to start, I'd just get stuck. &lt;em&gt;Where do I begin? What should the folder structure look like?&lt;/em&gt; I'd spend time googling, jumping between tutorials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now I just ask.&lt;/strong&gt; I ask it to help me create a plan, tell me what problems might come up, suggest a stack, suggest a folder structure, or explain how this kind of thing is built in the real world.&lt;/p&gt;

&lt;p&gt;For example: I wanted to build a website for my project in Python. Before, I could only think about JS/HTML/CSS. AI introduced me to Streamlit — a small library with limited control, but it was the right fit for that project.&lt;/p&gt;

&lt;p&gt;And when I don't know how something works, I ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Explain X as if I'm a complete beginner."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It explains in a Socratic way, so I'm actually learning — not just copy-pasting. I also use this when picking up something new, or I ask it to create a quiz for me.&lt;/p&gt;




&lt;p&gt;So that's just about one month of actively using AI — and I think I'm only using &lt;strong&gt;10–20% of its full potential&lt;/strong&gt;. But I already have a feel for how to use it. I don't feel as lost and frustrated as I did last time.&lt;/p&gt;

&lt;p&gt;If things still feel foggy and unclear — there's only one way to figure it out: &lt;strong&gt;try it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Try it, play with it, build with it. After enough hours of experimenting you'll figure out by yourself: which style works best for you, how you like to learn with it, what you want to use it for. But also — don't forget to think critically. Don't take everything AI says as truth. If something feels off or unclear, check it yourself.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What are your takeaways? How long have you been using AI?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devjournal</category>
      <category>learning</category>
      <category>programming</category>
    </item>
    <item>
      <title>Where's the line between programming and using AI?</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Mon, 26 Jan 2026 15:53:20 +0000</pubDate>
      <link>https://forem.com/snikmas/wheres-the-line-between-programming-and-using-ai-40hi</link>
      <guid>https://forem.com/snikmas/wheres-the-line-between-programming-and-using-ai-40hi</guid>
      <description>&lt;h2&gt;
  
  
  Backstory
&lt;/h2&gt;

&lt;p&gt;I've known about vibe-coding for a long time, but I didn't really get what it actually was. Before, I thought it was just writing your code and asking AI to write some parts for you (like: go to browser → ask → it gives you code → done). Or ask Cursor. Yeah, I thought it worked like that.&lt;/p&gt;

&lt;p&gt;I also thought that when you learn new stuff (new stack, new language), best practice is doing everything on your own.&lt;/p&gt;

&lt;p&gt;For example: when I learned Java, Python, Spring—I could ask LLMs how this thing works, how that works, but I rarely asked them to write code for me. I also turned off auto-completion in PyCharm/IntelliJ, disabled Copilot, all of it.&lt;/p&gt;

&lt;p&gt;And then I was surprised that nowadays... almost nobody does this (or so I think). I have one friend who's genuinely one of the smartest guys I know (like really smart). He started a startup. He was shocked when I told him about my setup—especially turning off auto-completion.&lt;/p&gt;

&lt;p&gt;He told me nowadays he barely codes; most of the time AI codes for him. The only thing: he understands what it does. He could write it himself if needed. He was trying to hire interns and got angry: "nowadays most guys can vibe-code, but don't understand what is actually happening."&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%2Fr7lhcevlg4olxt8gftwy.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%2Fr7lhcevlg4olxt8gftwy.png" alt="True" width="606" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem:
&lt;/h2&gt;

&lt;p&gt;So I've been thinking. What am I supposed to code myself? What should I leave to AI?&lt;/p&gt;

&lt;p&gt;Because here's the thing—I can learn to write something myself. Really understand it. But an LLM can write it faster. Probably better. So what's left for me—just debugging LLM output?&lt;/p&gt;

&lt;p&gt;But if I'm not writing code, I'm not practicing. I'm not getting better at it. Like: you write every day → more experience → new ideas come. Like a muscle. But if you give this to AI... what happens?&lt;/p&gt;

&lt;p&gt;And I'm a CS student with no real experience. I don't know what the rules are anymore. What should I actually be able to do myself? Are there things I don't need to understand deeply anymore?&lt;/p&gt;

&lt;p&gt;Before, I thought the answer was simple: be able to write everything yourself. But now guys are just vibe-coding and shipping faster.&lt;/p&gt;




&lt;h2&gt;
  
  
  My current situation:
&lt;/h2&gt;

&lt;p&gt;I'm working on portfolio projects right now. Never built this type before—lots of steps, 70% I've never learned. Asked AI for a roadmap (steps, what to learn).&lt;/p&gt;

&lt;p&gt;Currently I just finished reading about the requests library in Python. It's really easy; I think there's no problem asking AI to write it for me. But I want to try at least once on my own, for practice—to actually check if I understand it or just &lt;em&gt;think&lt;/em&gt; I understand it.&lt;/p&gt;

&lt;p&gt;Because that's another thing: you can read docs and feel like you get it, but until you write it yourself, you don't know for sure.&lt;/p&gt;

&lt;p&gt;So I put a temporary rule for using LLMs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the docs first&lt;/li&gt;
&lt;li&gt;Try to code as much as you can yourself
If you're stuck: ask the LLM for a hint or a template, not ready-to-use code. Or, if you really understand the problem—give it all the details, describe the whole process so it can write code that you could have written yourself&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's probably not the best approach. Just something I came up with because I don't know what else to do.&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%2Fchrjp93yzpp0a9fidk37.gif" 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%2Fchrjp93yzpp0a9fidk37.gif" alt="Puzzled" width="300" height="207"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  So...
&lt;/h2&gt;

&lt;p&gt;Thanks for reading this mess of thoughts!&lt;br&gt;
How are you guys handling this? What do you code yourself, and what do you give to AI?&lt;/p&gt;

</description>
      <category>programming</category>
      <category>vibecoding</category>
      <category>ai</category>
      <category>discuss</category>
    </item>
    <item>
      <title>LeetCode Series: SlidingWindow (3/5)</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Tue, 23 Sep 2025 11:45:53 +0000</pubDate>
      <link>https://forem.com/snikmas/leetcode-series-slidingwindow-35-5g65</link>
      <guid>https://forem.com/snikmas/leetcode-series-slidingwindow-35-5g65</guid>
      <description>&lt;p&gt;Hi there! I've been busy learning new tech (and again: ended up in "tutorial-loop-hell"). &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today, we will learn the sliding window technique — pretty useful and it covers a huge amount of problems on LeetCode.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sliding Window
&lt;/h3&gt;

&lt;p&gt;See the word substring in a problem? In about 80% of cases, that’s a hint to use a sliding window.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Longest / Maximum / Minimum&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Substring / Subarray / Block&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;... of size k / length k&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In some sense, it’s a kind of two-pointers pattern: whenever you deal with consecutive elements, that’s usually a sliding window.&lt;/p&gt;

&lt;p&gt;The idea: use two pointers to track a range of elements — that’s your window. You can expand it, shrink it, whatever the problem needs. You only care about the elements inside the window; the rest of the array? You don’t care about it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Two types of sliding window
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fixed-size window → window size doesn’t change; move the two pointers along the array.&lt;/li&gt;
&lt;li&gt;Dynamic window → window can shrink or grow depending on the problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  General Approach
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Initialize leftPtr = 0, rightPtr = 0 (optionally track window length). &lt;/li&gt;
&lt;li&gt;While rightPtr &amp;lt; arr.length:
2.1. Expand the window by moving rightPtr++ if your condition allows.
2.2 Shrink the window by moving leftPtr++ if needed.&lt;/li&gt;
&lt;li&gt;Process whatever you need inside the window.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s a code example:&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%2Fh14bj3j5y4vp8rr65kv4.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%2Fh14bj3j5y4vp8rr65kv4.png" alt=" " width="725" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s try to solve a LeetCode problem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  643. Maximum Average Subarray I
&lt;/h1&gt;

&lt;p&gt;In short:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an integer array nums&lt;/li&gt;
&lt;li&gt;nums length n&lt;/li&gt;
&lt;li&gt;integer k&lt;/li&gt;
&lt;li&gt;find a subarray of length k with the max average and return it&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Approach
&lt;/h3&gt;

&lt;p&gt;A subarray.. of length k? → a sliding window. A fixed-size sliding window.&lt;br&gt;
First, let’s find the subarray with the maximum sum. In the end, divide that sum by k to get the average."&lt;/p&gt;

&lt;p&gt;Step 1: Compute the first window (minimum size should be k → it will be our first max).&lt;/p&gt;

&lt;p&gt;Step 2: Slide the window — expand and shrink as needed in each iteration. Create a sum variable equal to our max. While sliding, update sum and compare it with max.&lt;/p&gt;

&lt;p&gt;Step 3: In this problem, they ask us to return a double. Okay, return it and don’t forget to divide by k — they still ask us for the average.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code
&lt;/h3&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%2Fmaju9m165s2doag2ikma.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%2Fmaju9m165s2doag2ikma.png" alt=" " width="538" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time: O(n) - no brute force with O(n^2)&lt;/li&gt;
&lt;li&gt;Space: O(1) - we don’t need any data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary - Key Points to Remember
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Sliding Window = a two-pointer technique for problems involving consecutive elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Common keywords: longest, maximum, minimum, substring, subarray, block, “of size k”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Two types: Fixed-size and Dynamic window&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;General approach:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start with left = 0, right = 0.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand window by moving right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shrink window by moving left if needed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;That's all for today!&lt;/p&gt;

&lt;p&gt;In the next 2 sections, I’d like to explain two topics that are also a bit hard for me (they also require knowledge of trees and graphs). It will be challenging, but also pretty interesting! See you next time /smile/&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>java</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>When a Simple Project Becomes a Terminal Debugging Nightmare</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Sat, 13 Sep 2025 13:02:33 +0000</pubDate>
      <link>https://forem.com/snikmas/when-a-simple-project-becomes-a-terminal-debugging-nightmare-2357</link>
      <guid>https://forem.com/snikmas/when-a-simple-project-becomes-a-terminal-debugging-nightmare-2357</guid>
      <description>&lt;p&gt;Hello, today I wanna start with my news:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I’ve finally finished my uni-project: Dictionary&lt;/strong&gt; 🎉&lt;/p&gt;

&lt;p&gt;Well, in the beginning it wasn’t hard: create a menu, let the user choose some options, give them an input to translate, send it to some API, get the result and output it.&lt;/p&gt;

&lt;p&gt;Pretty easy, doesn’t it? Okay, let’s add “save” and “history” options.  Well, the terminal version looks a little boring… just like:&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%2Fox3jmn4g4qdovpvofn30.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%2Fox3jmn4g4qdovpvofn30.png" alt=" " width="707" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not good. I want pictures! I want cute animations!  … that’s how I came across &lt;strong&gt;ncurses&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;That’s how it went from an enjoyable — moderately hard program — to a super hard program that you have to debug for days.&lt;/p&gt;




&lt;h2&gt;
  
  
  My process:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Dictionary
&lt;/h3&gt;

&lt;p&gt;I had to find a dictionary to translate words. There were 2 options: offline and online. I wanted experience with &lt;strong&gt;online APIs&lt;/strong&gt;, so I naturally chose the online version.  &lt;/p&gt;

&lt;p&gt;Next, what to use? I wondered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Online translators (Google/Baidu — a Chinese Google) are paid + many western sites don’t work well in China. This project is for my professors, so I wanted them to run it without problems.&lt;/li&gt;
&lt;li&gt;DeepSeek — well… it doesn’t have a public API.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When I thought that was over, by chance, I found a Chinese translate AI API: &lt;a href="https://ai.youdao.com/" rel="noopener noreferrer"&gt;Youdao AI Translate&lt;/a&gt; (be careful: fully in Chinese).  &lt;/p&gt;

&lt;p&gt;Good! I could still do my project. Onward: &lt;strong&gt;write code&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Coding the foundation
&lt;/h3&gt;

&lt;p&gt;The root idea was pretty simple. I think I finished it in ~3–4 days:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Menu&lt;/strong&gt;: translate with 2 modes: &lt;code&gt;CN→EN&lt;/code&gt; and &lt;code&gt;EN→CN&lt;/code&gt;; history; saved words; exit  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data structure&lt;/strong&gt;: store word in English, word in Chinese, and &lt;code&gt;isFavorite&lt;/code&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At first, I wanted to add transcription/pinyin, but that requires more requests… well, basics first, maybe later.
&lt;/li&gt;
&lt;li&gt;Used &lt;strong&gt;linked lists&lt;/strong&gt; for saved/history words
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Create API request&lt;/strong&gt;: challenging, but I liked it:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;uuid&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;openssl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cJSON&lt;/code&gt; (totally different than JavaScript)
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Actually, I didn’t want to use &lt;code&gt;curl&lt;/code&gt; at first: I tried sending requests myself using a proxy…  &lt;/p&gt;

&lt;p&gt;But that added too much complexity. At that time, I didn’t fully understand what kind of program this would be, so I chose &lt;code&gt;curl&lt;/code&gt;. Proxy can wait for next time.  &lt;/p&gt;

&lt;p&gt;The app was ready and worked well.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Enter ncurses
&lt;/h3&gt;

&lt;p&gt;Oh, here we are. My enjoyable program became my &lt;strong&gt;most hated program&lt;/strong&gt; — rewriting the whole structure 2–3 times.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happened?&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I wanted to add &lt;strong&gt;mascots&lt;/strong&gt;. Stored in double-linked lists.
&lt;/li&gt;
&lt;li&gt;Iterating through double lists using pointers — one more class for me.
&lt;/li&gt;
&lt;li&gt;Connection issues: I use VPN in China. Sometimes it threw unexpected errors.
&lt;/li&gt;
&lt;li&gt;OS: originally Linux program. On Windows (thanks WSL 🙏), still unexpected behaviors sometimes.
&lt;/li&gt;
&lt;li&gt;Fonts in Chinese: Unicode, not ASCII. Terminal didn’t support Unicode initially. After hours, sometimes I saw characters; next day, garbage.
&lt;/li&gt;
&lt;li&gt;Reorganized folder structure: initially ncurses in one file, logic in another. Here're we go again: Messy spaghetti code started.
&lt;/li&gt;
&lt;li&gt;Ncurses windows: every window has coordinates. Had to track x, y carefully. Thanks, linear algebra classes!
&lt;/li&gt;
&lt;li&gt;Buffer nightmare: &lt;code&gt;scanf&lt;/code&gt; leaves &lt;code&gt;\n&lt;/code&gt;, ncurses windows also have buffers. Had to clear them every time.
&lt;/li&gt;
&lt;/ul&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%2F48oj5dr6wct3gv6dnsrb.jpg" 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%2F48oj5dr6wct3gv6dnsrb.jpg" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, I used ChatGPT for help. Just guidance. Not full copy-paste... Sometimes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I didn’t understand a bug →
&lt;/li&gt;
&lt;li&gt;Ask ChatGPT →
&lt;/li&gt;
&lt;li&gt;Read explanation carefully →
&lt;/li&gt;
&lt;li&gt;Try code/copy →
&lt;/li&gt;
&lt;li&gt;Doesn’t work → repeat 5+ times
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the end, I couldn’t understand anything, so I rewrote everything in a new file. Frustrating, but totally worth it.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Final thoughts
&lt;/h3&gt;

&lt;p&gt;I finished the last line, ran it, and thought: &lt;strong&gt;GOOD ENOUGH, I FINISHED IT!&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Then debugging time began… Makefile helped a lot, but imagine all the errors it showed: &lt;code&gt;malloc&lt;/code&gt; issues, missing headers, wrong function order. 😅&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%2F4ix6701j356dap0un7e2.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%2F4ix6701j356dap0un7e2.png" alt=" " width="700" height="717"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Even though it was harder than expected, I really like this project (even if it’s still buggy). I learned a lot:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sockets, SSL/TLS, OpenSSL, UUID&lt;/strong&gt;: handling internet requests in C and understanding the differences between Windows and Linux.
Big thanks to Ed Harmoush (@PracticalNetworking) and Jacob Sorber (@JacobSorber)! I learned all the topics mentioned above from their YouTube tutorials, which were really helpful for my project 😄&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cJSON&lt;/strong&gt;: JSON parsing in C.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error handling&lt;/strong&gt; – malloc/pointers issues, input buffers, ncurses buffers (it was hard)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ncurses&lt;/strong&gt; – terminal UI and animations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linked lists, data structures, buffers&lt;/strong&gt;: deeper understanding.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Makefile&lt;/strong&gt;: first time learning automated compilation.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;README&lt;/strong&gt;: writing a clean, portfolio-ready GitHub page.
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This project taught me patience, debugging, and how to bring a terminal program to life. And most importantly — I still love it ❤️ &lt;/p&gt;

&lt;p&gt;If you’ve read until this line — wow, thanks for your time! I really appreciate it 😅&lt;/p&gt;

</description>
      <category>c</category>
      <category>programming</category>
      <category>sideprojects</category>
      <category>beginners</category>
    </item>
    <item>
      <title>LeetCode series: Two Pointers (2/4)</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Fri, 12 Sep 2025 15:26:11 +0000</pubDate>
      <link>https://forem.com/snikmas/leetcode-series-two-pointers-24-2jh1</link>
      <guid>https://forem.com/snikmas/leetcode-series-two-pointers-24-2jh1</guid>
      <description>&lt;h2&gt;
  
  
  LeetCode and Two Pointers
&lt;/h2&gt;

&lt;p&gt;Hi, Nice to see you! I hope you’re doing well 😄&lt;/p&gt;

&lt;p&gt;Today we will learn the Two Pointers technique, a simple yet powerful strategy for traversing arrays or strings.This is must have for solving problems in LeetCode.&lt;/p&gt;




&lt;h2&gt;
  
  
  Two Pointers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use two indices (pointers) to traverse a data structure.&lt;/li&gt;
&lt;li&gt;The pointers don’t have to move in sync — it depends on the problem.&lt;/li&gt;
&lt;li&gt;Common types:

&lt;ol&gt;
&lt;li&gt;Opposite ends (start and end of array/string)&lt;/li&gt;
&lt;li&gt;Same direction (slow/fast pointer)&lt;/li&gt;
&lt;li&gt;Expanding around the center&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Common goals:

&lt;ul&gt;
&lt;li&gt;meet in the middle (palindrome check; opposite ends)&lt;/li&gt;
&lt;li&gt;move at different speeds (fast/slow pointer, same direction)&lt;/li&gt;
&lt;li&gt;merge two sorted array&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;In short: choose two indices, check conditions while iterating, and move pointers as needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In most cases, it requires a sorted array&lt;/li&gt;
&lt;li&gt;Time Complexity: O(n) or O(log n) (depending on the problem)&lt;/li&gt;
&lt;li&gt;Space Complexity: O(1). pretty good&lt;/li&gt;
&lt;li&gt;Pretty basic but fundamental, that also can be used for another techniques (sliding window)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Where to use?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Text analysis: palindromes, substrings, symmetry.&lt;/li&gt;
&lt;li&gt;Removing duplicates from arrays.&lt;/li&gt;
&lt;li&gt;Searching or filtering data efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, this is a must-have technique. It’s not only useful for solving LeetCode problems but also very practical in real-world jobs.&lt;/p&gt;

&lt;p&gt;Okay, that’s enough. Let’s practice&lt;/p&gt;




&lt;h2&gt;
  
  
  Problem: 125. Valid Palindrome
&lt;/h2&gt;

&lt;p&gt;In short: given a string, determine whether it is a palindrome.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ignore punctuation, spaces, and symbols.&lt;/li&gt;
&lt;li&gt;Case doesn’t matter (&lt;code&gt;"S"&lt;/code&gt; and &lt;code&gt;"s"&lt;/code&gt; are the same).&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Take 2-3 minutes to think about how to use the two pointers technique to check if a word is a palindrome:&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;palindrome&lt;/strong&gt; is a word/number/sentence that &lt;strong&gt;reads the same forwards and backwards&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of it as an &lt;strong&gt;array&lt;/strong&gt; that is &lt;strong&gt;the same&lt;/strong&gt; forwards and backwards.&lt;/p&gt;

&lt;p&gt;Any ideas?  &lt;/p&gt;

&lt;h3&gt;
  
  
  Approach
&lt;/h3&gt;

&lt;p&gt;For problems that check &lt;strong&gt;palindromes&lt;/strong&gt;, using two pointers from opposite ends solves about 80% of them.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set two pointers at the ends of the string&lt;/li&gt;
&lt;li&gt;Iterate from the ends to the center using a loop: while leftPtr &amp;lt; rightPtr&lt;/li&gt;
&lt;li&gt;Skip everything except letters and digits&lt;/li&gt;
&lt;li&gt;Compare the characters ignoring case&lt;/li&gt;
&lt;li&gt;Move pointers: leftPtr++(forward) and rightPtr— (backward)&lt;/li&gt;
&lt;li&gt;If no mismutch is found: return true → the string is a palindrome, Congrats! You got it!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&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;boolean&lt;/span&gt; &lt;span class="nf"&gt;isPalindrome&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// two pointers: opposite ends&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;left&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;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&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="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&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="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isLetterOrDigit&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;charAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;)))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&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="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isLetterOrDigit&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;charAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;)))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;right&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="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toLowerCase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;charAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nc"&gt;Character&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toLowerCase&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;charAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;))){&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;

            &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
            &lt;span class="n"&gt;right&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="kc"&gt;true&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time:&lt;/strong&gt; O(n)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Space:&lt;/strong&gt; O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;given:  String s = “We panic in a pew!”&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input: &lt;code&gt;"We panic in a pew!"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;left = 0&lt;/code&gt; → &lt;code&gt;'W'&lt;/code&gt; (letter)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;right = 17&lt;/code&gt; → &lt;code&gt;'!'&lt;/code&gt; (skip non-letter → move to &lt;code&gt;'w'&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Compare &lt;code&gt;'W'&lt;/code&gt; and &lt;code&gt;'w'&lt;/code&gt; → match → move pointers inward&lt;/li&gt;
&lt;li&gt;Continue comparing &lt;code&gt;'e'&lt;/code&gt; and &lt;code&gt;'e'&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;All matches → return &lt;code&gt;true&lt;/code&gt; → the string is a palindrome&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Summary – Key Points to Remember
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;two pointers technique&lt;/strong&gt; is a useful method to traverse arrays or strings, especially for tasks like checking palindromes, removing duplicates, or searching efficiently.&lt;/li&gt;
&lt;li&gt;In most cases, the &lt;strong&gt;array should be sorted&lt;/strong&gt; for optimal use (though this is not always required).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s all for this article.&lt;/p&gt;




&lt;p&gt;In the next section, I will introduce another technique: &lt;strong&gt;sliding window&lt;/strong&gt; (which also uses the two pointers concept).&lt;/p&gt;

&lt;p&gt;Explaining all types of problems for each case would take a lot of text (even for this topic—we haven’t explored checking duplicates yet). I may write another article where I select some problems and briefly explain their approaches.&lt;/p&gt;

&lt;p&gt;Also, I want to try to include diagrams, because I know how hard it is to read long text without any visuals 😄&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading, and see you next time!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>leetcode</category>
      <category>algorithms</category>
      <category>java</category>
    </item>
    <item>
      <title>LeetCode series: Data Structures (1/4)</title>
      <dc:creator>snikmas</dc:creator>
      <pubDate>Mon, 08 Sep 2025 13:27:44 +0000</pubDate>
      <link>https://forem.com/snikmas/leetcode-series-data-structures-14-23k6</link>
      <guid>https://forem.com/snikmas/leetcode-series-data-structures-14-23k6</guid>
      <description>&lt;h2&gt;
  
  
  LeetCode and Data Structures
&lt;/h2&gt;

&lt;p&gt;Hi! 👋 Currently, I’m preparing for my internship next year, and these days I’m working hard on LeetCode problems.  &lt;/p&gt;

&lt;p&gt;At first, I thought it was enough to just:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Try solving a problem
&lt;/li&gt;
&lt;li&gt;Check the solutions
&lt;/li&gt;
&lt;li&gt;Understand the idea
&lt;/li&gt;
&lt;li&gt;Try it again
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Well… it works. But honestly, you’ll be faster (and way less frustrated) if you know some &lt;strong&gt;common patterns&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;In the next few posts, I’d like to write a series about the most popular techniques that can help you solve about &lt;strong&gt;60–70% of problems on LeetCode (easy → medium level).&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;In this post, I want to introduce some &lt;strong&gt;basic data structures&lt;/strong&gt;. Once you figure out how these work, you’ll be able to understand most of the others much more easily.  &lt;/p&gt;




&lt;h2&gt;
  
  
  What’s a data structure?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;data structure&lt;/strong&gt; is just a way to efficiently store data. That’s it.  &lt;/p&gt;

&lt;p&gt;But it’s really important to choose the &lt;strong&gt;right one&lt;/strong&gt; for the &lt;strong&gt;right task&lt;/strong&gt;. Otherwise, you’ll waste time (and get frustrated) trying to figure out which operations make sense for the structure you picked — or why your time complexity suddenly jumps to &lt;code&gt;O(n^2)&lt;/code&gt; just because you tried to add a few characters to a string.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String[] myFamily = {"Rick", "Morty", "Summer", "Beth", "Jerry"};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Array&lt;/strong&gt; is a linear, continuous data structure used for storing data.  &lt;/p&gt;

&lt;p&gt;Most common example: think about a row of lockers with numbers (indices). You open one and put your data inside.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some features:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strings are arrays of characters.
&lt;/li&gt;
&lt;li&gt;Access time: &lt;code&gt;O(1)&lt;/code&gt; → you know your locker, just open it and get your value. &lt;em&gt;mmm, nice, love it.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Insert/Delete at the end/start: &lt;code&gt;O(1)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Insert/Delete in the middle: &lt;code&gt;O(n)&lt;/code&gt; (not &lt;code&gt;n^2&lt;/code&gt;, so not terrible — just shift N elements).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where to use:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traversing a structure in order
&lt;/li&gt;
&lt;li&gt;Accessing specific indices
&lt;/li&gt;
&lt;li&gt;Comparing elements from both ends
&lt;/li&gt;
&lt;li&gt;Sliding window, prefix sum, etc.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. String
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String heroName = "Morty";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, strictly speaking, &lt;strong&gt;string is not a data structure&lt;/strong&gt;, but it deserves to be mentioned.  &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;string is basically an array of characters.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main things to remember:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In memory, a string really &lt;em&gt;is&lt;/em&gt; an &lt;strong&gt;array of characters&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutable&lt;/strong&gt; in most languages: for example, when you do &lt;code&gt;"dog" + "s"&lt;/code&gt;, it doesn’t change the first string — it creates a totally new one.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checking for anagrams
&lt;/li&gt;
&lt;li&gt;Returning a substring that matches a pattern
&lt;/li&gt;
&lt;li&gt;Finding the longest substring without repeating characters
&lt;/li&gt;
&lt;li&gt;String problems are &lt;em&gt;not&lt;/em&gt; for brute-force solutions — you’ll need smart techniques.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Set
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HashSet&amp;lt;Integer&amp;gt; mySet = new HashSet&amp;lt;&amp;gt;();
mySet.add(0);
mySet.add(1);
mySet.add(6);
mySet.add(5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set&lt;/strong&gt; is a collection of unique variables. That’s it.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some features:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access time: &lt;code&gt;O(1)&lt;/code&gt; (usually)
&lt;/li&gt;
&lt;li&gt;Stores only &lt;strong&gt;unique elements&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where to use it:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you need uniqueness
&lt;/li&gt;
&lt;li&gt;When you want to check for existence
&lt;/li&gt;
&lt;li&gt;When you need fast membership checks (&lt;code&gt;Array&lt;/code&gt; needs &lt;code&gt;O(n)&lt;/code&gt;, &lt;code&gt;Set&lt;/code&gt; does it in &lt;code&gt;O(1)&lt;/code&gt;)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Map (Dictionary)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HashMap&amp;lt;String, String&amp;gt; contacts = new HashMap&amp;lt;&amp;gt;();
contacts.put("me", "123-123-123");
contacts.put("dad", "000-000-000");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;strong&gt;map&lt;/strong&gt; is a collection of key–value pairs. Like a phone book: &lt;code&gt;name → phone number&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access: &lt;code&gt;O(1)&lt;/code&gt; (usually); worst case is &lt;code&gt;O(n)&lt;/code&gt; but rare
&lt;/li&gt;
&lt;li&gt;Keys must be unique
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where to use it:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Counting frequencies
&lt;/li&gt;
&lt;li&gt;Caching
&lt;/li&gt;
&lt;li&gt;Mapping indices
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;That’s it for the &lt;strong&gt;basic data structures&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
All the others (trees, graphs, linked lists, etc.) are like &lt;em&gt;upgraded versions&lt;/em&gt; of these four. If you nail these, you’ll pick up the rest much more easily.  &lt;/p&gt;

&lt;p&gt;In my next posts, I’ll cover &lt;strong&gt;common patterns&lt;/strong&gt; and &lt;strong&gt;real LeetCode problems&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;I hope you liked this post — see you later! 👋  &lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>datastructures</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
