13 Pins1 Followers

Two linked lists A and B are joined on a particular node, called the point of intersection of the linked lists. Find the point of intersection, i.e. the first node after which both lists have same nodes. Algorithm uses a hash. Here is a video to find if two linked lists intersect with the help of examples and animations. The algorithm has O(m+n) time and O(n) space complexity.Java code is provided in Code Snippet section.

1

Given a linked list, detect the starting node for a loop in that list if a loop exists in it. This should be done in O(1) space and O(n) time complexity. Here is a video solution that explains the intuition behind Floyd's algorithm with animations and examples.

Given a binary tree, convert it into a doubly linked list. The doubly linked list should be created such that nodes follow inorder traversal of the binary tree. Java solution is provided in code snippet section. Java visualization is provided in algorithm visualization section.

Given a linked list and a number k, reverse every alternate k nodes of the list. Java code is provided in code snippet section. Java visualization is provided in algorithm visualization section.

Given a linked list having n nodes. Reverse the list using recursive approach. Here is a video solution that reverses a linked list recursively. Explained the algorithm with the help of examples and animations.Java code is provided in Code Snippet Section.

Given a linked list having n nodes. Reverse the list using iterative method. Here is a video solution that reverses a linked list iteratively using 3 pointers. Explained the algorithm with the help of examples and animations.Java code is provided in Code Snippet Section.

Implement Least Recently Used (LRU) cache. Least Recently Used cache replacement algorithm is a cache replacement strategy by which the least recently accessed page is removed from the cache when a new page is accessed which is not already present in the cache. Java solution is provided in code snippet section. Java visualization is provided in algorithm visualization section.

Given 2 sorted linked lists, merge the lists to a single sorted linked list. Java solution is provided in code snippet section. Java visualization is provided in algorithm visualization section.

Given a doubly linked list in sorted order with previous and next nodes. Convert the doubly linked list to a binary search tree with left as previous node and right as next node. This should be done in-place. Java solution is provided in code snippet section. Java visualization is provided in algorithm visualization section.

Two linked lists list1 and list2 are joined a particular node, called the point of intersection of the linked lists. Find the point of intersection, i.e. the first node after which both lists have same nodes. Desired order is O(m + n) Time Complexity and O(1) Space Complexity. Here is a video to find if two linked lists intersect with the help of examples and animations.Java code is provided in Code Snippet section.

Pinterest • The world’s catalogue of ideas