Problem Solving: Write code to remove duplicates from an unsorted linked list.
Problem
Write code to remove duplicates from an unsorted linked list.Solution
Two types of solution came to my mind 1) Use hashmap to check the duplicates and remove that as necessary. Time complexity for this solution is O(n) and Space Complexity O(n) 2) We also can check if by checking all previous entries for duplciate. In this case time complexity will be O(n^2) and Space Complexity O(1)
Comments
Post a Comment