Day 8 / 100 Days of Code Challenge 💻🔥 Solved LeetCode 160 — Intersection of Two Linked Lists 🔗 🔍 Problem • Given two singly linked lists, find the node where they intersect • If no intersection exists, return null ⚙️ Approach (Two Pointer Switching) • Use two pointers starting at headA and headB • Traverse both lists simultaneously • When a pointer reaches the end, redirect it to the other list’s head 🔄 • Continue until both pointers meet • The meeting point is the intersection node (or null if no intersection) 💡 Key Learning • Equalizing path lengths without explicitly calculating them • Efficient pointer manipulation technique • Clean and optimal solution without extra space ⏱ Complexity • Time: O(n + m) ⏳ • Space: O(1) 📦 Consistency continues 🚀 #100DaysOfCode #LeetCode #DSA #LinkedList #ProblemSolving #Consistency
LeetCode 160: Intersection of Two Linked Lists
More Relevant Posts
-
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
-
-
🚀 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
To view or add a comment, sign in
-
-
🚀 Day 58 of #100DaysOfCode Today, I solved LeetCode 2840 – Check if Strings Can be Made Equal With Operations II, a problem that builds upon string manipulation and constraint-based transformations. 💡 Problem Overview: Given two strings, the objective is to determine whether they can be made equal using a defined set of swap operations. The challenge lies in understanding which positions can influence each other. 🧠 Approach: To efficiently solve this problem, I focused on: ✔️ Identifying independent index groups based on allowed operations ✔️ Separating characters into even and odd indexed groups ✔️ Comparing sorted/grouped characters from both strings This ensures correctness while maintaining optimal performance. ⚡ Key Takeaways: Identifying independent groups simplifies complex transformations Sorting/grouping techniques are effective for comparison problems Understanding constraints leads directly to optimal solutions 📊 Complexity Analysis: Time Complexity: O(n log n) Space Complexity: O(n) Small improvements every day lead to significant growth over time 🚀 #LeetCode #100DaysOfCode #DSA #Strings #ProblemSolving #CodingJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
🧠 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 6/100 — LeetCode Challenge Solved LeetCode 704: Binary Search Simple problem, but it tests your understanding of the basics. 💡 Approach: 1) Use two pointers: low and high 2) Find mid element 3) Compare with target and eliminate half of the search space 👉 Repeat until target is found or search space becomes empty. What I realized: Binary Search is not just about the idea, but about handling boundaries correctly (low <= high, mid calculation, etc.) 🧠 Time Complexity: O(log n) 💾 Space Complexity: O(1) Sometimes mastering the basics is more important than jumping to advanced problems. Back to consistency 💪 #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #CodingJourney
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 77 of LeetCode Problem Solving Journey — 100 Days LeetCode Challenge Today, I solved LeetCode #141 — Linked List Cycle using C++, under the guidance of Trainer NEKAL SINGH SALARIA Singh at REGex Software Services. 🔍 Problem Summary: Given the head of a linked list, determine if the list contains a cycle. A cycle exists if a node can be revisited by continuously following the next pointer. 🧠 Approach Used (Floyd’s Cycle Detection - Two Pointers): I used the slow and fast pointer technique: Initialize two pointers → slow and fast Move slow by one step and fast by two steps If there is a cycle → both pointers will eventually meet If fast reaches NULL → no cycle exists This approach efficiently detects cycles without extra space. 📚 Key Learnings of the Day ✔ Floyd’s algorithm is efficient for cycle detection ✔ Fast pointer helps identify loops quickly ✔ No extra memory is required ✔ Pointer movement patterns are crucial in linked list problems ⏱ Complexity • Time Complexity: O(n) • Space Complexity: O(1) 💡 Optimization Insight: Using a hash set is another approach but requires O(n) space, whereas the two-pointer method is optimal with constant space. Consistency is paying off — see you on Day 78 🚀 #Day77 #100DaysLeetCodeChallenge #LeetCode #RegexSoftwareServices #NekalSingh #ProblemSolving #DSA #CPlusPlus #CodingChallenge #ProgrammingJourney #LinkedList #KeepGrowing
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
-
-
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 62 of #100DaysOfCode 💻 Solved: Third Maximum Number (LeetCode 414) 🔍 Problem Statement: Given an integer array, return the third distinct maximum number. If it doesn’t exist, return the maximum number instead. 💡 Approach: The key here is “distinct” values — duplicates don’t count. First, focus on identifying unique numbers Then track the top 3 maximum distinct values If less than 3 distinct values exist → simply return the largest Instead of sorting (which adds extra cost), we can efficiently keep track of the top 3 values while traversing the array once. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) (if done optimally) 📌 Key Learning: This problem teaches how to optimize by avoiding sorting and how to maintain multiple maximums efficiently in a single pass. #Day62 #LeetCode #DSA #CodingJourney #PlacementPrep
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