Intersection of two sorted linked lists
Given two lists sorted in increasing order, create and return a new list representing the two lists’ intersection. The new list should be made with its memory – the original lists should not be changed.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven two lists sorted in increasing order, create and return a new list representing the two lists’ intersection. The new list should be made with its memory – the original lists should not be changed.
Given a linked list, sort it using the merge sort algorithm. Merge sort is an efficient, general-purpose sorting algorithm that produces a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output.
Write a function that takes two lists, each of which is sorted in increasing order, and merges the two into a single list in increasing order, and returns it.
Given two linked lists, merge their nodes to make one list, taking nodes alternately between the two lists. If either list runs out, all the nodes should be taken from the other list.
Given a linked list, split it into two lists containing alternating elements from the original list. The elements in the new lists may be in any order.
Rearrange a given linked list such that every even node will be moved to the end of the list in reverse order.
Given a linked list, move its front node in front of another given list.
Given a linked list sorted in increasing order, write a function that removes duplicate nodes from the list by traversing it only once.
Given a list, split it into two sublists – one for the front half and one for the back half. If the total number of elements is odd, the extra element should go in the front list.
Given a linked list, write a function to rearrange its nodes to be sorted in increasing order.
Given a sorted list in increasing order and a single node, insert the node into the list’s correct sorted position. The function should take an existing node and rearranges pointers to insert it into the list.
Write a pop() function that is the inverse of push(). The pop() function takes a non-empty list, deletes the head node, and returns the head node’s data.