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 (0)