𝗗𝗮𝘆 𝟯𝟮/𝟭𝟬𝟬 | 𝗥𝗲𝗺𝗼𝘃𝗲 𝗡𝘁𝗵 𝗡𝗼𝗱𝗲 𝗙𝗿𝗼𝗺 𝗘𝗻𝗱 𝗼𝗳 𝗟𝗶𝘀𝘁 Day 32 ✅ — Three linked list problems in a row. The pattern is clear. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟭𝟵: Remove Nth Node From End of List (Medium) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Remove the nth node from the end of a linked list in one pass... or two. The tricky part? We don't know the size upfront. My approach: first calculate the size, then find the exact node to remove. Key edge case that almost caught me: removing the head node itself (when n equals the list size). Had to handle that separately. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 First pass: calculate the total size of the linked list 👉 If n equals size, remove head directly 👉 Traverse to the node just before the target 👉 Skip the target node: curr.next = curr.next.next Time complexity: O(n), Space complexity: O(1) 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: This is a two-pass solution. There's also a one-pass two-pointer technique using fast and slow pointers—something I want to explore next. But here's what matters: my solution works, is clean, and handles all edge cases. Understanding multiple approaches to the same problem is what separates good developers from great ones in technical interviews. Three linked list problems back-to-back (Day 30, 31, 32) and the pointer manipulation is becoming second nature. 𝗖𝗼𝗱𝗲: https://lnkd.in/g5EEbZKW 𝟯𝟮 𝗱𝗮𝘆𝘀. 𝗟𝗶𝗻𝗸𝗲𝗱 𝗹𝗶𝘀𝘁 𝗺𝗮𝘀𝘁𝗲𝗿𝘆 𝘂𝗻𝗹𝗼𝗰𝗸𝗲𝗱. 𝗗𝗮𝘆 𝟯𝟮/𝟭𝟬𝟬 ✅ | 𝟲𝟴 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #PointerManipulation #TwoPointer #DataStructures #CodingInterview #TechnicalInterview #FAANG #SoftwareEngineer #Java #Algorithms #EdgeCases #ComputerScience #Programming #TechCareers #Consistency

To view or add a comment, sign in

Explore content categories