Day 165/365 of the DSA grind!
Pure Backtracking today:
• Combinations: The classic Add -> Recurse -> Remove boilerplate.
• Permutations: Skipped the visited array! Used in-place element swapping to save memory.
• Combination Sum: Reusing numbers? Just pass i instead of i+1 into the recursive call to keep picking it!
#DSA #Java #100DaysOfCode #LeetCode #Backtracking
Day 164/365 of the DSA grind!
Learning Tries (Prefix Trees) today!
• Implement Trie: Built the standard 26-child node structure for instant O(L) lookups.
• Add & Search Words: Added recursive DFS to the Trie to handle . wildcards!
• Word Search II (Hard): Built a Trie of the dictionary first, then ran DFS on the grid to instantly prune invalid paths.
#DSA #Java #100DaysOfCode #LeetCode #SoftwareEngineering
Day 163/365 of the DSA grind!
From BFS Shortest Paths to Backtracking today:
• Word Ladder (Hard): Graph BFS! Swapped chars 'a' to 'z' to find the shortest path.
• Minimum Genetic Mutation: Literally Word Ladder but with only A, C, G, T. Reused the template!
• Letter Combinations: Classic backtracking. Build the string, recursively explore, and deleteCharAt to backtrack.
#DSA #Java #100DaysOfCode #LeetCode #Algorithms
Day 162/365 of the DSA grind!
Demystifying Topological Sort today!
• Evaluate Division: Modeled math equations as directed weighted graphs. DFS to calculate the path product!
• Course Schedule: Kahn's Algorithm! Tracked dependencies with an inDegree array to detect impossible cycles.
• Course Schedule II: Same Kahn's template, just recorded the queue pops to map the exact path!
#DSA #Java #100DaysOfCode #LeetCode #Graphs
Day 161/365 of the DSA grind!
Deep into Graphs today:
• Surrounded Regions: Worked backwards! Ran DFS from the edges to mark safe zones, then flipped the rest.
• Clone Graph: Used a HashMap to map originals to clones and dodge infinite loops.
• Snakes and Ladders: Shortest path = BFS! Flattened the zigzag 2D board into a 1D array to simulate dice rolls cleanly.
#DSA #Java #100DaysOfCode #LeetCode #Graphs
Day 160/365 of the DSA grind!
Officially crossing into Graphs today!
• Number of Islands: Used the "sink the island" DFS trick. Modifying the grid in-place saves so much memory!
• Validate BST: Passed absolute min and max boundaries down the stack to avoid structural traps.
• Kth Smallest Element: In-order traversal. Just stopped tracking the moment count == k.
#DSA #Java #100DaysOfCode #LeetCode #SoftwareEngineering
Day 159/365 of the DSA grind!
Reusing templates and exploiting BST rules today:
• Level Order Traversal: The standard BFS Queue boilerplate.
• Zigzag Level Order: Same BFS code, just added a boolean flag and Collections.reverse() to flip every other level!
• Minimum Absolute Difference: In-order traversal gives sorted order automatically. Tracked a prev pointer to calculate differences on the fly with O(1) space.
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 158/365 of the DSA grind!
Learning the BFS Queue template today!
• Lowest Common Ancestor: If a node gets a hit from both its left and right branches, it's the LCA!
• Right Side View: Level-order traversal. Just grabbed the last node of every level.
• Average of Levels: Same BFS boilerplate, just averaged the level sums!
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 157/365 of the DSA grind!
Exploiting tree structures today!
• Binary Tree Max Path Sum (Hard): Used post-order DFS to track global maxes while returning single-path gains.
• BST Iterator: Paused an in-order traversal using a Stack for clean O(h) memory!
• Count Complete Tree Nodes: Skipped the full traversal. Compared left/right depths and used bitwise shifts (1 << height) for an instant count!
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 156/365 of the DSA grind!
Passing state through trees today!
• Flatten Binary Tree: Used a reverse post-order traversal (Right, Left, Root) to rewire the tree in O(1) space!
• Path Sum: Subtracted from the target down to the leaves.
• Sum Root to Leaf: Shifted decimals dynamically down the stack (current * 10 + val).
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 155/365 of the DSA grind!
Building trees and bending pointers today:
• Construct Tree (Pre/In): Mapped the inorder array to a HashMap for O(1) root lookups to avoid nested loops!
• Construct Tree (In/Post): Same HashMap trick, but working backward from the postorder tail.
• Next Right Pointers II: Banned from using a Queue? Used a Dummy Node to link the next level like a Linked
List instead
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 154/365 of the DSA grind!
System design patterns and famous tree problems today:
• LRU Cache: Paired a HashMap with a custom Doubly Linked List for pure O(1) caching!
• Invert Binary Tree: The legendary Google Homebrew problem! Just 3 lines of recursive swapping.
• Symmetric Tree: Mirrored recursion checking outer and inner branches.
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 153/365 of the DSA grind!
Hello Binary Trees!
• Partition List: Built two separate dummy lists (one for smalls, one for bigs) and stitched them together.
• Max Depth of Binary Tree: Trees = recursion! Math.max(left, right) + 1.
• Same Tree: Clean recursive structural checks.
#DSA #Java #100DaysOfCode #LeetCode #BinaryTrees
Day 152/365 of the DSA grind!
Wrapping up Linked Lists today!
• Remove Nth Node From End: Used a Fast/Slow pointer gap to find the target in exactly one pass.
• Remove Duplicates II: Dummy node + skipping entire chunks of clones.
• Rotate List: Connected the tail to the head to make a circular list, then just snipped it at the new pivot point! O(N) magic.
#DSA #Java #100DaysOfCode #LeetCode #LinkedLists
Day 151/365 of the DSA grind!
Advanced Linked Lists and a LeetCode Hard today!
• Copy List with Random Pointer: Skipped the HashMap! Wove the clones directly into the original list for O(1) space.
• Reverse Linked List II: Dummy node + sublist front-shifting.
• Reverse in k-Group (Hard): Basically just repeating sublist reversals. Draw your pointers on paper!
#DSA #Java #100DaysOfCode #LeetCode #LinkedLists
Day 150/365 of the DSA grind!
Entering the Linked List chapter today:
• Linked List Cycle: Fast & slow pointers. If they meet, there's a loop!
• Add Two Numbers: Elementary math simulation with a carry tracker.
• Merge Two Sorted Lists: Pointer rewiring made easy with a Dummy Node.
#DSA #Java #100DaysOfCode #LeetCode #LinkedLists
Day 149/365 of the DSA grind!
Deep dive into Stacks today:
• Min Stack: Ran two parallel stacks to track historical minimums for O(1) retrieval.
• Evaluate RPN: The classic postfix evaluator! Push numbers, pop for operators.
• Basic Calculator (Hard): Used a stack to "pause and resume" the running total whenever hitting parentheses!
#DSA #Java #100DaysOfCode #LeetCode #Stacks
Day 148/365 of the DSA grind!
Wrapping up Intervals and diving into Stacks today!
• Burst Balloons: Sorted by the end coordinates to greedily maximize overlapping shots.
• Valid Parentheses: The classic Push/Pop bracket matching!
• Simplify Path: Used a Stack as a directory history tracker to parse Unix file paths.
#DSA #Java #100DaysOfCode #LeetCode #Stacks
Day 147/365 of the DSA grind!
Learning the Intervals pattern today!
• Summary Ranges: Tracked consecutive numbers and logged the breaks.
• Merge Intervals: The classic! Sorted by start times, then stretched the boundaries using Math.max().
• Insert Interval: Skipped the full sort! Used a 3-part while loop to cleanly splice and merge the new interval in pure O(N) time.
#DSA #Java #100DaysOfCode #LeetCode #Algorithms