Igor Mazhitov’s Post

View profile for Igor Mazhitov, graphic

Software Engineer | 2.5+ years of experience | JavaScript, TypeScript, NodeJS, React, Angular, PostgreSQL, AWS, GIT, Docker

🚀 LeetCode Daily Challenge 6/100 🚀 📊 Medium 🎯 Problems: Rotate List, Remove Duplicates from Sorted List II 💡 Solutions: - Remove Duplicates from Sorted List II --> Iterate through the linked list to find duplicate values --> if a value is the same as the next value, add it to a set called duplicates --> Iterate through the linked list again --> for each node, if its value is not in duplicates, add it to the new linked list --> return the new linked list, or null if there are no non-duplicate values. - Rotate List --> find the length of the linked list --> calculate the actual rotation amount k by taking k % length --> if k is 0 or the linked list is empty, return the original linked list --> move the fast pointer k steps forward --> move both fast and slow pointers until fast reaches the end of the linked list --> set the next of the end node to the head node to form a circular linked list --> update the head to the node next to the slow pointer and set the next of slow to null to break the loop. 🚧 Complexity Analysis: - Remove Duplicates from Sorted List II Time complexity: O(n), where n is the number of nodes in the linked list. Space complexity: O(n) due to the set duplicates potentially containing all unique values in the linked list. - Rotate List Time complexity: O(n), where n is the number of nodes in the linked list. Space complexity: O(1) #LeetCode #DailyChallenge #Medium #LinkedList #Algorithms #SoftwareDevelopment #Developer #Tech #Coding #DataStructures #JavaScript #TypeScript #React #NodeJS #Java #ProblemSolving #CodeChallenge #Recruiters #BigTechCompanies #FAANG #MAMAA #Google #Amazon #Meta #Microsoft #Connections #Engineering #STEM #TechTrends #Innovation #SoftwareEngineering #Coding

To view or add a comment, sign in

Explore topics