🚀 Day 32 Out of #365DaysOfCode -LeetCode ✅ LeetCode Problem Solved: Delete the Middle Node of a Linked List I solved the Delete the Middle Node problem on LeetCode by analyzing the length of the linked list and removing the middle element in a clean and structured way. 🔹 Approach Used: First traversed the linked list to calculate its total size Identified the middle index using size / 2 Traversed again to reach the node just before the middle Adjusted pointers to delete the middle node safely 🔹 Key Concepts Practiced: Linked List traversal Pointer manipulation Edge case handling (empty list or single node) 🔹 Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) 📌 This problem helped strengthen my understanding of linked list operations and pointer-based problem solving in Java. #LeetCode #Java #LinkedList #DSA #ProblemSolving #CodingPractice #InterviewPreparation #LearningJourney Github link: https://lnkd.in/gGUy_MKZ
LeetCode Problem Solved: Delete Middle Node of Linked List
More Relevant Posts
-
Day 23 of #100DaysOfLeetCode 💻✅ Solved #19. Remove Nth Node From End of List on LeetCode using Java. Approach: • Used a dummy node to handle edge cases (like removing the head) • Initialized two pointers: fast and slow • Moved fast pointer n+1 steps ahead to maintain a gap • Traversed both pointers together until fast reached null • Slow pointer stopped just before the node to delete • Updated links to remove the target node in one pass Performance: ✓ Runtime: 0 ms (Beats 100% submissions) ✓ Memory: 43.77 MB Key Learning: ✓ Mastered two-pointer (fast & slow) technique ✓ Understood importance of dummy node for edge cases ✓ Solved the problem in a single traversal (O(n) time, O(1) space) Consistency is building confidence 🚀 #Java #LeetCode #DSA #LinkedList #TwoPointers #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 20 of #100DaysOfLeetCode 💻✅ Solved #21. Merge Two Sorted Lists problem on LeetCode in Java. Approach: • Handled edge cases where either list is empty • Used a dummy node to simplify merging logic • Maintained a pointer current to build the new list step-by-step • Compared nodes from both lists and linked the smaller one • Connected any remaining nodes after one list ends • Returned dummy.next as the new head of the merged list Performance: ✓ Runtime: 0 ms (Beats 100% submissions) ✓ Memory: 44.26 MB (Beats 75% submissions) Key Learning: ✓ Strengthened understanding of linked list pointer manipulation ✓ Learned to merge two lists without creating extra nodes ✓ Improved confidence in multi-pointer problems and list traversal Learning one problem every single day 🚀 #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 36 – Solving LeetCode Problem 🚀 📌 Problem: 49. Group Anagrams 🟡 Difficulty: Medium 🧠 Key Idea: Anagrams share the same character frequency Sort each string to create a unique key Use a HashMap to group strings with identical sorted keys 💡 What I reinforced today: Effective use of HashMap for grouping problems How string normalization (sorting) simplifies comparisons Writing clean and optimized Java code Understanding time complexity trade-offs ⚙️ Approach: Convert each word to a char array Sort it to form a key Map the key to a list of original strings 📈 Complexity: Time: O(n · k log k) Space: O(n · k) Consistency over comfort. One problem at a time. 💪 #Day36 #LeetCode #DSA #Java #HashMap #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 35 📌 LeetCode : Minimum Depth of Binary Tree Today I solved the Minimum Depth of Binary Tree problem using Java. The goal was to find the shortest path from the root node to the nearest leaf node. I applied a recursive approach while carefully handling edge cases where one subtree is null. Instead of directly taking the minimum of both sides, I ensured the solution correctly skips null paths to avoid incorrect depth calculations. 📌 Key takeaways: 🔹 Understood the difference between minimum and maximum depth logic 🔹 Learned the importance of handling null child nodes 🔹 Strengthened recursion and tree traversal concepts 🔹 Improved problem-solving accuracy in edge cases This problem helped me think more clearly about tree structures and reinforced the importance of precise base conditions in recursion. #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 26 of #100DaysOfLeetCode 💻✅ Solved #203. Remove Linked List Elements on LeetCode using Java. Approach: • Handled edge cases by removing matching nodes from the beginning of the list • Traversed the linked list using a pointer • Checked the next node’s value instead of the current node • If value matched, updated links to skip the node • Maintained in-place modification without using extra data structures Performance: ✓ Runtime: 1 ms (Beats 95.94% submissions) ✓ Memory: 47.62 MB Key Learning: ✓ Improved understanding of linked list pointer manipulation ✓ Learned how to handle head node edge cases carefully ✓ Strengthened in-place deletion logic in singly linked lists Learning one problem every single day 🚀 #Java #LeetCode #DSA #LinkedList #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Solved: Two Sum II (Sorted Array | Two-Pointer Technique | Java) NeetCode Implemented an efficient solution to find two numbers in a sorted array that add up to a given target. 🔍 Approach: Used the Two-Pointer technique Initialized one pointer at the beginning and one at the end Compared the sum and adjusted pointers accordingly Returned 1-based indices as required This approach avoids nested loops and keeps the solution clean and efficient. 💡 Key Learnings: Leveraging sorted array properties Writing optimized logic without extra data structures Improving pointer-based problem solving Consistent problem-solving practice strengthens logical thinking and code efficiency. #Java #DSA #CodingPractice #ProblemSolving #SoftwareDevelopment
To view or add a comment, sign in
-
-
Solved today’s LeetCode Daily Question using Java. Algorithm Traverse the array once to detect a strictly increasing sequence. Identify the peak element where the trend changes. Continue traversal while the sequence is strictly decreasing. Validate that there is exactly one peak and the traversal ends at the last index. Why this works A single-pass greedy scan ensures O(n) time complexity and constant space while rejecting invalid multiple-trend patterns early. Result • Runtime: 1 ms (beats 72.27%) • Memory: 44.62 MB (beats 64.71%) • 871/871 test cases passed #leetcode #algorithm #dsa #java #problemSolving #softwareengineering
To view or add a comment, sign in
-
-
Day32 - LeetCode Journey Solved LeetCode 415: Add Strings in Java ✅ This problem was a great reminder that fundamentals matter. Adding two numbers digit by digit without converting them into integers really pushes you to think like the computer does. By traversing both strings from right to left, handling the carry carefully, and building the result step by step, the solution stays clean and efficient. It’s simple logic, but getting all the edge cases right makes a big difference. Key takeaways: • Practiced manual addition logic using strings • Strengthened understanding of carry handling • Reinforced O(n) time complexity thinking • Avoided built-in shortcuts like BigInteger Another solid step forward in mastering string-based problems. Consistency is doing its work 💪 #LeetCode #DSA #Java #Strings #Algorithms #ProblemSolving #CodingPractice #InterviewPreparation #Consistency #DailyCoding
To view or add a comment, sign in
-
-
🚀 Day 76 of #100DaysOfCode Today I solved a string manipulation problem: Clear Digits 🧠 Problem: Given a string, whenever a digit appears, remove the previous character. Digits act like a backspace operation. 💡 Key Insight: Instead of modifying the string directly (since Strings are immutable in Java), I used a StringBuilder, which works like a stack: If character → append (push) If digit → delete last character (pop) 📌 What I Learned: StringBuilder is powerful for string modifications Always handle edge cases (like digit at the start) Many string problems are actually stack problems in disguise ⏱ Complexity: Time: O(n) Space: O(n) #Java #DSA #LeetCode #CodingJourney #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 91 of #100DaysOfCode | LeetCode Daily Solved LeetCode Problem #693 – Binary Number with Alternating Bits 🔢💡✅ A clean and elegant bit manipulation problem. The trick is to XOR the number with its right shift and check if the result becomes all 1s — simple, fast, and effective. Key Takeaways: -> Using n ^ (n >> 1) to detect alternating patterns -> Leveraging highestOneBit() for boundary checks -> Writing concise, branch-free logic with bitwise ops -> Sometimes the smartest solutions are the shortest Language: Java -> Runtime: 0 ms (Beats 100%) -> Memory: 41.81 MB (Beats 97.08%) One more day, one more concept sharpened. 🔥 Onward to Day 92 💻🚀 #LeetCode #Java #BitManipulation #BinaryNumbers #ProblemSolving #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