DEV Community

Deekshitha
Deekshitha

Posted on

🚀 LeetCode Top 150 — Progress Log #1

I’ve officially started my Top 150 LeetCode journey to strengthen my foundations in Data Structures & Algorithms.

Progress: 3 / 150 Problems Solved

Rather than rushing through problems, my focus is on understanding patterns, improving reasoning, and writing cleaner solutions over time.


🧩 Problems Solved Today

1️⃣ Merge Sorted Array

Approach:
Merged elements from the second array into the first and applied sorting to maintain order.

Key Learning:
A working solution isn’t always the optimal one. This problem introduced the importance of thinking about pointer-based merging instead of relying purely on sorting.

class Solution {
public:
    vector<int> merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
        for(int i = m; i < m + n; i++) {
            nums1[i] = nums2[i - m];
        }
        for(int i = 0; i < m + n - 1; i++) {
            for(int j = 0; j < m + n - i - 1; j++) {
                if(nums1[j] > nums1[j+1]) {
                    swap(nums1[j], nums1[j+1]);
                }
            }
        }
        return nums1;
    }
};
Enter fullscreen mode Exit fullscreen mode

2️⃣ Remove Element

Approach:
Used a write pointer (idx) to overwrite unwanted values in-place.

Key Learning:
Many array problems reduce to maintaining a correct write index rather than deleting elements.

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int idx = 0;
        for(int i = 0; i < nums.size(); i++){
            if(nums[i] != val){
                nums[idx++] = nums[i];
            }
        }
        return idx;
    }
};
Enter fullscreen mode Exit fullscreen mode

3️⃣ Remove Duplicates from Sorted Array

Approach:
Compared current element with the previous one and stored only unique values using a pointer.

Key Learning:
Sorted arrays unlock simpler logic — recognizing structure in input data is powerful.

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        if(nums.empty()) return 0;
        int idx = 1;
        for(int i = 1; i < nums.size(); i++) {
            if(nums[i] != nums[i-1]) {
                nums[idx++] = nums[i];
            }
        }
        return idx;
    }
};
Enter fullscreen mode Exit fullscreen mode

🧠 Reflection

Early DSA problems look simple, but they build essential habits:

  • thinking in-place,
  • minimizing extra memory,
  • recognizing reusable patterns.

This challenge isn’t about speed — it’s about consistent improvement.

📍 Next Target: Top 150 continues…

If you’re also working on DSA or building consistency in problem solving, let’s grow together.

🔗 GitHub — https://github.com/CodeWithDeeksh
🐦 X — https://x.com/deekshithax

One problem at a time. Consistency over intensity.

Top comments (1)

Collapse
 
just_another_react_dev profile image
Just another Dev • Edited

all the best for your DSA journey even i am on DSA journey recently switched programming language to learn DSA (javascript --> Python)
one thing that i would like to add is
start solving easier problem first to keep the momentum.