Reverse a doubly linked list
In this post, we will see how to reverse a doubly linked list using iteration and recursion.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedIn this post, we will see how to reverse a doubly linked list using iteration and recursion.
Given a linked list, pairwise swap its adjacent nodes. The swapping of data is not allowed, only links should be changed.
Given a linked list that can grow in both horizontal and vertical directions (right and down), flatten it into a sorted singly linked list provided that each horizontal and vertical list is already sorted.
Given a linked list of strings, check whether the concatenation of all values in the list together forms a palindrome. It is not permissible to construct a string out of the linked list nodes and check that string for palindrome.
Given a list that can grow in both horizontal and vertical directions (right
and down
), flatten it into a singly linked list. The conversion should be in such a way that the down
node should be processed before the next
node for any node.
Given a linked list, swap the k’th
node from the beginning with the k’th
node from the end. The swapping should be done so that only links between the nodes are exchanged, and no data is swapped.
Given a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes a 45–degree angle with the parent.
Given a binary tree, write an efficient algorithm to link nodes at the same level in the form of a linked list like structure.
Given a multilevel linked list, convert it into a singly linked list so that all nodes of the first level appear first, followed by all nodes of the second level, and so on.
This post provides an overview of several methods to implement a linked list in Python.. A Linked List node consists of a data field and a reference to the next node in the list.
Given a linked list, rearrange it by separating odd nodes from even ones. All even nodes should come before all odd nodes in the output list, and the relative order of even and odd nodes should be maintained.
Given two sorted linked lists, merge them without using extra space without modifying links of the first list. The solution should preserve the sorted order of elements in both lists.