𝗗𝗮𝘆 𝟰𝟵/𝟭𝟬𝟬 | 𝗥𝗲𝗺𝗼𝘃𝗲 𝗗𝘂𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝘀 𝗳𝗿𝗼𝗺 𝗦𝗼𝗿𝘁𝗲𝗱 𝗟𝗶𝘀𝘁 𝗜𝗜 Day 49 ✅ — One day from halfway. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟴𝟮: Remove Duplicates from Sorted List II (Medium) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Remove ALL nodes that have duplicates, not just the extras. If a value appears twice, remove both occurrences. Day 35: Kept one copy of duplicates. Day 49: Remove all duplicates entirely. The difference? An inner while loop to skip ALL duplicate values, then reconnect prev to the node after the duplicate chain. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Dummy node for clean head handling 👉 Detect duplicates: curr.val == curr.next.val 👉 Inner loop: skip ALL duplicate nodes 👉 Reconnect: prev.next = curr.next 👉 Move forward only when no duplicates found Time: O(n), Space: O(1) 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Twenty linked list problems (Day 30-49). The progression from Day 35's "keep one" to Day 49's "remove all" shows how small changes in requirements test true understanding. Tomorrow: Day 50. Halfway milestone. The journey continues. 𝗖𝗼𝗱𝗲:🔗 https://lnkd.in/g-tqpNVB 𝗗𝗮𝘆 𝟰𝟵/𝟭𝟬𝟬 ✅ | 𝟱𝟭 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #DataStructures #CodingInterview #SoftwareEngineer #Java #Algorithms #Programming #AlmostHalfway #Day50Tomorrow

To view or add a comment, sign in

Explore content categories