Graph BFS and DFS Traversals
Before I approach LeetCode graph problems, I have to familiarise myself with useful graph operations.
I'll continue with this tomorrow and proceed to LeetCode afterwards
Day 20 of #30DaysOfDSA
Construct a Binary Tree from Preorder and Inorder Traversal
Took me HOURS.
This wasn't medium in any way, shape, or form.
I'll solve some more tree problems today and move on to Graphs tomorrow.
Day 19 of #30DaysOfDSA
Problem: Unique Binary Search Trees
Couldn't solve this completely myself because I failed to realize the properties of a Binary "Search" Tree.
But now I get it.
Day 17 of #30DaysOfDSA
Problem: N-ary Tree Preorder Traversal
Was pretty nice solving this, just had to get past the bad leetcode descriptions.
This would be my last stack problem. On to Trees
Day 16 of #30DaysOfDSA
Problem: Min Stack
Well, once I understood that getMin() wasn't actually removing the min.
It wasn't too bad to implement all O(1) time functions
Day 14 of #30DaysOfDSA
Actually, scrap that, I came up with something faster.
The first solution helped me realize this is just a sum of products
So I did it in one pass, constant memory
Day 13 of #30DaysofDSA (Part 2 lol)
Day 11 of #30DaysOfDSA
Problem: Compare Version Numbers
This was fairly straightforward tbh
I'm comfortable with two pointers now, moving on to stacks
Unfortunately, there is no native Queue data structure in JS.
Day 10 of #30DaysOfDSA
Problem: Sort Colors
Perfect example of a medium 2-pointer problem.
Honestly, didn't think one pass was possible, but here we are.
Day 6 of #30DaysOfDSA
Sorting.
1. 2.. 3...
Revisited all the popular sorting algorithms and noted each of their time complexities.
Most interesting is how insertion sort can go from O(n^2) to O(n) depending on the array π
Day 5 of #30DaysOfDSA
Arithmetic Slices.
Safe to say, I'm done with sliding windows
Took me a while, but I got the maths down
Finding all >= 3 subsets of an arithmetic sequence
On to sorting.
Day 4 of #30DaysOfDSA
Longest Substring Without Repeating Characters.
I did not think I'd like sliding windows, after yesterday π
Just a classic sliding window
The left pointer, right pointer, and a Set
Every time a duplicate appears:
Move left until itβs valid again
Day 2 of #30DaysOfDSA
Problem: Find the Duplicate Number
I couldn't solve this myself π . The solution was not intuitive at all.
Turning the array into a linked list in your mind, then applying Floydβs Cycle Detection
Iβll be studying fast/slow pointer patterns deeper today
Day 1 of #30DaysOfDSA π
Solved: Search in 2D Matrix
Approach:
β Treated the matrix as a flattened sorted array
β Applied binary search
β Converted mid index back to row/col
Time: O(log(m*n))
Space: O(1)
Small wins stack.
Day 5/30
Diving into loops in C todayβfor, while, and do-while.
From repetition to logic building, this is where DSA starts to feel powerful πͺ
One loop at a time, consistency > motivation.
#30DaysOfDSA#Cplusplus#DSA#CodingJourney#BuildInPublic