🚀 Day 17/100 — LeetCode Challenge Solved Reverse Linked List At first, it feels tricky because we need to change the direction of links without losing the list. 💡 Approach (Iterative): 1) Use three pointers: prev, curr, next 2) Store the next node 3) Reverse the link (curr → prev) 4) Move all pointers forward 👉 Repeat until the list is fully reversed 💡 Key Insight: We’re not just moving through the list, we’re rebuilding it in reverse order. 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) 💡 What I learned: Linked List problems are less about logic, and more about careful pointer handling. One small mistake = broken list. #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #CodingJourney
Reverse Linked List Challenge on LeetCode
More Relevant Posts
-
🧠 Day 32/75: Solving for the "End" from the "Beginning" Linked Lists can be tricky because you can't access elements by index. So, how do you remove the Nth element from the back without knowing the total length? Today’s LeetCode session was a deep dive into Pointer Logic. By maintaining a specific distance between two pointers, I was able to identify and delete the target node in a single traversal. Current Progress: 📅 32 Days Consecutive 🎯 Focus: Advanced Linked List Patterns ⚡ Result: 100% Beats Runtime Another day, another problem solved. The second month is off to a strong start! 💻🔥 #Consistency #100DaysOfCode #DSA #CodingJourney #JavaDeveloper #TechGrowth #LeetCodeChallenge #LinkedInLearning
To view or add a comment, sign in
-
-
🚀 Day 14/100 — LeetCode Challenge Solved Delete Node in a Linked List The twist? 👉 You are not given the head of the list At first, I thought deletion wouldn’t be possible without the previous node. But the trick is: 1) Copy the value of the next node 2) Point current node to next->next 3) Effectively “delete” the next node instead 💡 Key Insight: Instead of deleting the given node directly, we shift values and bypass the next node. 🧠 Time Complexity: O(1) 💾 Space Complexity: O(1) 💡 What I learned: Sometimes problems are not about applying a pattern, but about thinking differently with given constraints. Switching from patterns to concepts now. #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #CodingJourney
To view or add a comment, sign in
-
-
Day 4/100 of my LeetCode Journey Back on track after a short break, and today’s problem was “Kth Smallest Element in a Sorted Matrix.” At first, I didn’t approach it correctly. I was thinking in terms of simple indexing, but this problem required a different perspective. I learned how a min heap can be used to efficiently track the smallest elements across multiple rows. Instead of checking the entire matrix, the idea is to always pick the smallest available element and move forward from there. What I noticed today is that my logic is improving, but I still need to be careful with implementation. Small syntax and indexing mistakes can break the whole solution even when the approach is right. Takeaway: Understanding the approach is important, but writing clean and correct code is equally important. Making steady progress, one problem at a time. Question: Do you also find implementation harder than understanding the logic? #Day4 #LeetCode #DSA #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Day 45/100 – LeetCode Challenge 🔗 Problem: Linked List Components (LeetCode 817) 💡 Difficulty: Medium Today’s problem was all about understanding connected components in a linked list using a smart approach. 🧠 Key Insight: Instead of checking every possible combination, I used a HashSet for quick lookups. A component is counted only when a sequence ends, i.e., when the current node is in nums but the next node is not. ⚡ Approach: Convert nums into a set for O(1) lookup Traverse the linked list Count only when a component ends 📈 Time Complexity: O(n) 📦 Space Complexity: O(n) ✨ What I learned: Sometimes, solving problems efficiently is about identifying where something ends rather than where it starts. Consistency is key 🔥 Halfway through the journey — staying committed! #Day45 #100DaysOfCode #LeetCode #DataStructures #LinkedList #CodingJourney #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 11/100 — LeetCode Challenge Solved Capacity To Ship Packages Within D Days The problem is not about finding an element… It’s about finding the minimum capacity that satisfies a condition. 💡 Approach: The answer lies between: 👉 max(weights) and sum(weights) 1) Apply binary search on this range 2) For each capacity, simulate shipping: -Count how many days it takes -If days ≤ given → try smaller capacity -Else → increase capacity 👉 This is a mix of binary search + greedy validation 🧠 Time Complexity: O(n log n) 💾 Space Complexity: O(1) 💡 What I learned: Whenever the problem asks for minimum/maximum value under a constraint, there’s a high chance it can be solved using binary search on answer. This pattern is getting clearer now. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #Greedy #CodingJourney
To view or add a comment, sign in
-
-
Day 18 / 100 Days of Code Challenge 💻🔥 Solved LeetCode 155 — Min Stack 📊 🔍 Problem • Design a stack that supports standard operations: push, pop, top • Additionally, implement getMin() to return the minimum element • All operations must run in O(1) time ⚙️ Approach (Two Stack Technique) • Use one stack to store all elements • Use another stack to keep track of minimum values • While pushing, store the current minimum • While popping, update the minimum accordingly 💡 Key Learning • Maintaining extra information in data structures • Efficient tracking of minimum without traversal • Understanding how to achieve constant time operations ⏱ Complexity • Time: O(1) for all operations ⚡ • Space: O(n) 📦 Consistency continues 🚀 #100DaysOfCode #LeetCode #DSA #Stack #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
LeetCode Progress 24/50 — Intersection of Two Arrays I worked on a problem focused on set operations and efficient lookup 🧩 💡 The challenge was to find the unique intersection of two arrays, ensuring no duplicate elements in the result. 🧠 Approach: Used hash sets to store elements and efficiently check for common values between both arrays. This ensured uniqueness and optimized lookup time. ⏱ Time Complexity: O(n + m) 💡 What I learned: This problem highlighted how set-based approaches simplify duplicate handling and improve efficiency in comparison tasks. 📈 Strengthening understanding of hashing and improving efficiency in array operations. #LeetCode #DSA #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
Most people understand cycle detection… but get stuck when asked to find where the cycle starts. 🚀 Day 19/100 — LeetCode Challenge Solved Linked List Cycle II 💡 Step 1: Detect cycle -Use slow & fast pointers -If they meet → cycle exists 💡 Step 2: Find starting node -Move fast back to head -Move both one step at a time -Where they meet again → start of cycle 👉 This part is pure intuition + math 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) 💡 What I learned: Detecting a cycle is easy. Finding its starting point is where real understanding begins. This is one of those problems where you either memorize… or truly understand. Have you ever understood why this works? #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #TwoPointers #CodingJourney
To view or add a comment, sign in
-
-
LeetCode Progress 37/50 — Remove Duplicates from Sorted List Today I worked on a problem focused on linked list traversal and in-place modifications 🧩 💡 The challenge was to remove duplicate nodes from a sorted linked list while preserving only one occurrence of each value. 🧠 Approach: Used pointer-based traversal to compare adjacent nodes and remove duplicates by updating links in-place whenever repeated values were found. ⏱ Time Complexity: O(n) 💡 What I learned: This problem reinforced how efficient pointer manipulation can simplify linked list operations without requiring extra space. 📈 Strengthening understanding of linked list fundamentals and improving confidence in pointer-based problem-solving. #LeetCode #DSA #LinkedList #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
🚀 Day 64/100 – LeetCode Challenge. 🔍 Problem: Valid Parentheses. Today’s problem was all about checking whether a string of brackets is valid or not. Sounds simple… but the trick lies in handling it efficiently! 💡 Approach Used: Stack (LIFO) 👉 Idea: Push opening brackets → ( { [ On closing bracket → check top of stack If match → pop Else → invalid ❌ 🧠 Key Insight: Stack helps maintain the correct order of brackets. The last opened bracket must be the first one to close. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(n) 📌 Takeaway: Whenever you see problems involving matching pairs / nested structures, think of using a stack! #100DaysOfCode #DSA #LeetCode #CodingJourney
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