🚀 Day 13/100 – #100DaysOfDSA Today was all about efficient deletion in Linked Lists and handling edge cases in a single pass 🔗 🔹 Problems Solved: 1. Remove Nth Node From End of List 2. Remove Duplicates from Sorted List 💡 Key Learnings: 👉 Problem 1: Remove Nth Node From End Used Two Pointer Technique (Fast & Slow) Move fast pointer n steps ahead Then move both pointers until fast reaches the end Slow will be just before the node to delete 👉 Key Trick: Use a dummy node to handle edge cases (like removing head) ✅ One-pass solution ✅ O(n) Time ✅ O(1) Space 👉 Problem 2: Remove Duplicates from Sorted List Since list is sorted → duplicates are adjacent Traverse and compare current node with next Skip duplicate nodes ✅ O(n) Time ✅ O(1) Space 🔥 What I learned today: Using dummy nodes + two pointers makes Linked List problems much cleaner and avoids edge-case bugs. Patterns are repeating, confidence is growing 📈 Day 13 done ✅ Let’s keep pushing 💪 #100DaysOfCode #DSA #LinkedList #ProblemSolving #CodingJourney #JavaScript #TechGrowth #SoftwareEngineer #LearningInPublic #Developers
Efficient Deletion in Linked Lists and Edge Cases
More Relevant Posts
-
🚀 Day 12/100 – #100DaysOfDSA Today was all about handling edge cases and smart traversal in Linked Lists 🔗 🔹 Problems Solved: 1. Intersection of Two Linked Lists 2. Remove Linked List Elements 💡 Key Learnings: 👉 Problem 1: Intersection of Two Linked Lists Used a HashSet approach Store nodes of one list and check in the other ✅ O(n + m) Time ❌ O(n) Space 💡 Optimization Insight: Can be solved using Two Pointer Technique with O(1) space Traverse both lists → switch heads → they meet at intersection 👉 Problem 2: Remove Linked List Elements Traverse the list and remove nodes matching given value Use a dummy node to handle edge cases (like removing head) 👉 Key Idea: Always keep track of previous node while deleting ✅ O(n) Time ✅ O(1) Space 🔥 What I learned today: Handling edge cases (like deleting head nodes or null cases) is just as important as solving the problem itself. Also learned that there’s always a more optimal solution worth exploring 👀 Day 12 done ✅ Let’s keep going strong 💪 #100DaysOfCode #DSA #LinkedList #ProblemSolving #CodingJourney #JavaScript #TechGrowth #SoftwareEngineer #LearningInPublic #Developers
To view or add a comment, sign in
-
🚀 Day 10/100 – #100DaysOfDSA Double digits! 🎯 Today was all about mastering Linked List traversal and pointer manipulation. 🔹 Problems Solved: 1. Middle of the Linked List 2. Reverse Linked List 💡 Key Learnings: 👉 Problem 1: Middle of the Linked List Used Two Pointer Technique (Slow & Fast pointers) Slow moves 1 step, Fast moves 2 steps When fast reaches end → slow is at the middle ✅ O(n) Time ✅ O(1) Space ✅ Efficient single-pass solution 👉 Problem 2: Reverse Linked List Iterative approach using three pointers: prev, current, next Reverse links one by one 👉 Core Idea: Change direction of next pointer at each step ✅ O(n) Time ✅ O(1) Space 🔥 What I learned today: Linked Lists are all about pointer control — once you master that, many problems become easier. The slow & fast pointer technique is 🔥 — super useful pattern! Day 10 done ✅ Staying consistent 💪 #100DaysOfCode #DSA #LinkedList #ProblemSolving #CodingJourney #JavaScript #TechGrowth #SoftwareEngineer #LearningInPublic #Developers
To view or add a comment, sign in
-
🚀 Day 2/100 – #100DaysOfDSA Continuing the journey with two interesting problems today! 🔹 Problems Solved: Best Time to Buy and Sell Stock Reverse String 💡 Key Learnings: 👉 Problem 1: Best Time to Buy & Sell Stock Used a greedy + two pointer mindset Track the minimum price so far (buy) and calculate profit at each step Update max profit whenever a better opportunity appears ✅ O(n) Time ✅ O(1) Space 👉 Problem 2: Reverse String Classic Two Pointer Technique One pointer at start, one at end Swap characters and move inward ✅ In-place solution ✅ No extra memory used 🔥 What I learned today: Sometimes the best solutions are not complex — just about tracking the right values at the right time. Consistency > Perfection. See you on Day 3 💪 #100DaysOfCode #DSA #LeetCode #ProblemSolving #CodingJourney #JavaScript #Developers #TechGrowth #SoftwareEngineer #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 5/100 – #100DaysOfDSA Today’s focus was on recursion and understanding how problems break down into smaller subproblems. 🔹 Problems Solved: 1. Power of Two 2. Fibonacci Number 💡 Key Learnings: 👉 Problem 1: Power of Two (Using Recursion) Base Case: n === 1 → true If n is divisible by 2, recursively check n / 2 If not divisible → false ✅ Clean recursive breakdown ✅ Helps understand divide-by-2 pattern 👉 Problem 2: Fibonacci Number (Using Recursion) Base Cases: F(0) = 0, F(1) = 1 Recursive Relation: F(n) = F(n-1) + F(n-2) ✅ Learned that: Simple recursion is intuitive 🔥 What I learned today: Recursion is powerful for understanding problem structure. Building consistency, one step at a time 💪 #100DaysOfCode #DSA #Recursion #LeetCode #ProblemSolving #CodingJourney #JavaScript #TechGrowth #SoftwareEngineer #LearningInPublic
To view or add a comment, sign in
-
🚀 DSA Day 18: Shifting Pointers & Linking Logic! 🔗🧠 Today was less about the theory and more about the logic. Implementing get, insert, and delete really forced me to see the code as a physical chain. The big "Aha!" moment: Realizing the power of O(1) insertions. In an array, adding to the front is a chore; here, you just move the head pointer and you’re done. ⚡️ It’s definitely a game of precision, though. If you don't handle the pointers in the right order—like making the "handshake" before breaking the old link—you lose your entire list to the void. 🕳️ Feeling way more confident with pointer logic now. On to Day 19! ➡️ #Day18 #JavaScript #DSA #LinkedList #CodingJourney #DataStructures #LearningInPublic #WebDev #LogicBuilding
To view or add a comment, sign in
-
-
🚀 Day 23 of #60DaysOfDSA Today I implemented Quick Sort, a powerful Divide & Conquer algorithm used for sorting. 🔍 What I learned: Quick Sort works by selecting a pivot element It partitions the array into: Elements smaller than pivot Elements greater than pivot Then recursively sorts both parts ⚡ Key Insight: “Partitioning is the heart of Quick Sort.” Even a small mistake in index handling or swapping can completely break the logic. 💻 Key Concepts Covered: ✔️ Pivot selection (last element) ✔️ Partition logic (Lomuto method) ✔️ Recursion ✔️ In-place sorting 🧠 Takeaway: Quick Sort is not just about writing code, it’s about understanding how elements move and how recursion divides the problem. Consistency > Perfection 🚀 One step closer to becoming better every day! #DSA #QuickSort #CodingJourney #JavaScript #ProblemSolving
To view or add a comment, sign in
-
-
Day 112 of #200DaysOfCode Leveling up Consistency continues, one concept at a time. Today I solved the "Memoize" problem on LeetCode using closures + caching in JavaScript. Key Idea: Avoid recomputing the same function call by storing previously calculated results. Approach: • Use a Map as cache storage • Convert arguments into a unique key using JSON.stringify() • If result already exists return cached value • Otherwise compute, store, and return result Concepts Used: • Closures • Memoization • Map • Higher Order Functions Time Complexity: • First Call → Depends on function • Repeated Calls → O(1) average lookup Space Complexity: O(n) Takeaway: Memoization is a powerful optimization technique that trades space for speed and is heavily used in Dynamic Programming and performance optimization. Learning not just to solve problems — but to make solutions smarter Let’s keep building #Day112 #200DaysOfCode #LeetCode #JavaScript #Memoization #Closures #CodingJourney #ProblemSolving #KeepGoing
To view or add a comment, sign in
-
-
🚀 Day 12 of My LeetCode Journey — Linked List Patterns Getting Stronger Today’s problems: 🔹 Intersection of Two Linked Lists (LeetCode 160) 🔹 Remove Linked List Elements (LeetCode 203) 💡 Problem 1: Intersection of Two Linked Lists Explored two approaches: ✅ Brute Force Traverse headA and check every node in headB ⏱️ Time: O(m × n) ✅ Using Set Store all nodes of headB in a Set Traverse headA and check for intersection ⏱️ Time: O(m + n) | 📦 Space: O(n) 👉 Helped me understand how hashing can optimize comparisons. 💡 Problem 2: Remove Linked List Elements Solved using a Sentinel (Dummy) Node 🔥 👉 Create a dummy node before head 👉 Use prev pointer to skip unwanted nodes: prev.next = prev.next.next This approach simplifies edge cases like: Removing head node Multiple consecutive deletions 🧠 What I Learned: Sentinel nodes make linked list problems cleaner Hashing can reduce time complexity significantly Thinking in terms of nodes (not values) is key 🔥 Key Takeaways: Always look for ways to reduce nested loops Dummy nodes = lifesaver in linked list problems Practice is making pointer manipulation more intuitive Grateful for the guidance from Namaste DSA and Akshay Saini 🚀 Day 13 loading… 💪 #LeetCode #DataStructures #Algorithms #CodingJourney #100DaysOfCode #SoftwareEngineering #Programming #InterviewPrep #JavaScript #CodingLife #TechGrowth #ProblemSolving #Developers #LearnToCode #LinkedList #DSA #NamasteDSA #AkshaySaini
To view or add a comment, sign in
-
🚀 Day 21 of #DevDSA 🔹 Problem: Merge Two Sorted Arrays (Using Extra Space) Today I worked on merging two sorted arrays into a single sorted array using an additional array. 🧠 Approach: Used two pointers (l for nums1 and r for nums2) Compared elements one by one Pushed the smaller element into a new mergedArray Handled equal elements by pushing both Continued until one array is exhausted 💡 Key Idea: Since both arrays are already sorted, we can efficiently merge them in linear time without sorting again. ⏱ Time Complexity: O(m + n) 📦 Space Complexity: O(m + n) 📌 What I learned: Two-pointer technique is very powerful for sorted data Writing clean conditions avoids unnecessary complexity Always think about edge cases (like remaining elements after loop) 💻 Next Step: Try solving the same problem without extra space (in-place optimization 🔥) #DSA #100DaysOfCode #CodingJourney #JavaScript #InterviewPrep
To view or add a comment, sign in
-
-
🌞 Back to LeetCode 75 – Day 43 ✅ 841. Keys and Rooms After a short break, I’m getting back into my daily problem-solving routine. Today’s problem was about checking whether we can visit all rooms starting from room 0, where each room contains keys to other rooms. Approach : This is basically a graph traversal problem in disguise. - Each room = a node - Keys = edges to other nodes So the task becomes: - Can we reach all nodes starting from node 0? I used an iterative DFS with a stack: - Start from room 0 - Use a visited array to track visited rooms - Keep exploring using available keys - Push unvisited connected rooms into the stack Complexity : - Time: O(N + K) - Space: O(N) Key Takeaway : Once you recognize this as a graph problem, the solution becomes straightforward. This is a good reminder that many array-like problems are actually graph problems in disguise. Restarting the consistency journey again — one problem at a time. 🚀 #LeetCode75 #Day43 #DSA #JavaScript #Graph #DFS #ProblemSolving #Coding #LearningInPublic #Consistency
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development