🚀 Day 29/100 – #100DaysOfCode Today’s problem: Middle of the Linked List (LeetCode 876) 🎯 💡 What I learned: How to find the middle node efficiently using the two-pointer (slow & fast) approach Understanding why the fast pointer moves twice as fast as the slow pointer Handling both odd and even length linked lists Writing optimal code with O(n) time and O(1) space 🧠 Key Idea: Use two pointers: slow → moves 1 step at a time fast → moves 2 steps at a time 👉 When fast reaches the end, slow will be at the middle! 📊 Complexity: Time: O(n) Space: O(1) 📈 One step closer to mastering Linked Lists..... #Day29 #100DaysOfCode #LeetCode #LinkedList #DSA #Java #CodingJourney #ProblemSolving #TechSkills
Solving Linked List Middle Node Problem with Two-Pointer Approach
More Relevant Posts
-
🚀 Day 27/100 Days of Code Challenge Today’s problem: Find Peak Element (Leetcode 162) 🔍 What I learned: How to find a peak element efficiently without scanning the entire array Using Binary Search to reduce time complexity from O(n) to O(log n) Understanding how the “slope” of elements helps decide the search direction 🧠 Key Idea: Instead of checking every element, compare the middle element with its neighbor: If nums[mid] < nums[mid + 1] → move right Else → move left ✅ Example: Input: [1, 2, 3, 1] Output: 2 (index of peak element 3) Consistency is key 🔑 — improving problem-solving skills one day at a time! 💪 #Day27 #100DaysOfCode #LeetCode #BinarySearch #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 28/100 – #100DaysOfCode Today’s problem: Reverse Linked List (LeetCode 206) 💡 What I learned: How to reverse a singly linked list using an iterative approach Managing pointers efficiently (prev, curr, next) Understanding how links change direction step by step 🧠 Key Idea: Instead of creating a new list, we reverse the links in-place: Store next node Reverse current pointer Move forward 📊 Complexity: Time: O(n) Space: O(1) Staying consistent, one problem at a time... #Day28 #100DaysOfCode #LeetCode #DSA #LinkedList #Java #CodingJourney #ProblemSolving #TechSkills
To view or add a comment, sign in
-
-
#Day72 Of Problem Solving Solved today’s LeetCode Daily Challenge ✅. Problem: Check if Binary String Has at Most One Segment of Ones Sometimes, the simplest logic gives the best results. Instead of overthinking, I went with a clean approach—just checking if "01" exists in the string. If it does, that means more than one segment of 1’s… and that’s it! ✔️ All test cases passed ⚡ Runtime: 0 ms 📊 Beat 100% in performance This problem was a good reminder that not every solution needs complexity—clarity matters more. Consistency > Complexity 🚀 On to the next challenge! #LeetCode #DailyChallenge #Java #ProblemSolving #CodingJourney #100DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
Day 2 of #LeetCodeDailyChallenge Showing up again — because consistency builds confidence. Today’s problem: Add Two Numbers 📌 Topic: Linked List ⚡ Difficulty: Medium What I focused on today: Traversing two linked lists together step-by-step Managing carry without breaking the flow Creating a result list dynamically while iterating Handling tricky edge cases (unequal lengths & leftover carry) This problem really helped me understand how small details (like carry) can impact the overall logic. Every day isn’t about solving something big — sometimes it's about understanding something better than yesterday. #DSA #LeetCode #Java #LinkedList #ProblemSolving #Consistency #LearningInPublic
To view or add a comment, sign in
-
Day 83 of #100DaysOfCode Today’s problem: Ugly Number An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Approach: Instead of checking all factors, I kept dividing the number by 2, 3, and 5 repeatedly: If the number reduces to 1 → it’s ugly ✅ If something else remains → not ugly ❌ 🔍 Key Insight: Efficient problem-solving is often about reducing complexity, not increasing checks. 🧠 What I learned: How to simplify factor-based problems Importance of repeated division in optimization Writing clean and efficient logic ⚡ Example: 6 → 2 × 3 → Ugly ✅ 14 → includes 7 → Not Ugly ❌ Consistency is slowly building confidence 💪 On to Day 84! #DSA #Java #CodingJourney #ProblemSolving #LeetCode #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 54 of my #100DaysOfCode Journey Today, I solved LeetCode – Sort Array By Parity II Problem Insight: Rearrange the array such that even-indexed positions have even numbers and odd-indexed positions have odd numbers. Approach: • Created a new result array of same size • Used two pointers: evenplace = 0 and oddplace = 1 • Traversed the array once • Placed even numbers at even indices and odd numbers at odd indices • Incremented pointers by 2 to maintain correct positions Time Complexity: O(n) | Space Complexity: O(n) Key Takeaway: Using two pointers for index placement makes the solution clean, efficient, and avoids unnecessary swaps. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Day 98 - LeetCode Journey Solved LeetCode 20: Valid Parentheses in Java ✅ A classic stack problem that looks simple but tests your attention to detail. The idea is straightforward: Push opening brackets into stack and match them correctly when a closing bracket appears. If anything mismatches → invalid. Clean logic, zero confusion 💡 Key takeaways: • Stack fundamentals • Matching pairs efficiently • Handling edge cases (empty stack, wrong order) • Writing clean conditional logic ✅ All test cases passed ⚡ O(n) time and O(n) space Sometimes basics like this are the real building blocks of strong DSA 🔥 #LeetCode #DSA #Java #Stack #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Day 17 of #100DaysOfCode Solved Plus One (Easy) today. A simple but important problem that reinforces handling edge cases carefully. Key Idea: Traverse from the last digit, handle carry properly. Approach: Start from the end of the array If digit < 9 → increment and return If digit == 9 → make it 0 and carry forward If all digits are 9 → create new array with leading 1 Learning: Even the easiest problems test your attention to edge cases. Consistency > Complexity. #LeetCode #DSA #CodingJourney #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 65/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 2535. Difference Between Element Sum and Digit Sum of an Array Used a single loop + digit extraction approach to calculate both element sum and digit sum efficiently. ⏱️ Time Complexity: O(n × d) 📦 Space Complexity: O(1) Strengthening understanding of number manipulation and digit-based operations. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 96 - LeetCode Journey Solved LeetCode 901: Online Stock Span in Java ✅ This problem is all about recognizing the pattern and using the right data structure. Instead of checking previous prices one by one, I used a Monotonic Stack to efficiently calculate spans. Every element is pushed and popped at most once → super optimized 🔥 Key idea: Keep removing smaller or equal previous prices and accumulate their spans. Key takeaways: • Monotonic Stack concept (very important) • Avoiding nested loops using stack optimization • Efficient span calculation • Thinking in patterns, not brute force ✅ All test cases passed ⚡ O(n) time and O(n) space This is one of those problems that truly levels up your stack game 💯 #LeetCode #DSA #Java #Stack #MonotonicStack #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
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
🔥☠️