Interleave List If input = [[1,2,3], [9, 0], [5], [-4,-5,-2,-3,-1]] then output = [1,9,5,-4,2,0,-5,3,-2,-3,-1];
Asked in Facebook F2F… Read More
Linked List
Difference between a LinkedList and a Binary Search Tree BST
Pointers
In a linked list, the items are linked together through a single next pointer.
Next Nodes
In a binary tree, each node can have 0, 1 or 2 subnodes, where (in case of a … Read More
In Given LinkedList Divide LL in N Sub parts and delete first K nodes of each part
Given LinkedList and K=2, N=41->2->3->4->5->6->7->8->9
so Partitioned LinkedList will be
1->2->3->4->5->6->7->8->9
Now delete first K nodes from each subpart and return
Reverse a Linked List in groups of given size
Example:
Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3
Output: 3->2->1->6->5->4->8->7->NULL.
Solution : Reverse a LinkedList keeping
Implement LRU Cache
Memory Efficient LinkedList
To use lesser memory in doubly link list, such data structure is used.
An ordinary doubly linked list stores addresses of the previous and next
flattens 2 D linked list to a single sorted link list
Write a function flatten() which flattens this linked list with each node down sorted link list to a single link list with all the elements in sorted order.
We have given Two methods in O(n^2)
Get K Max and Delete K Max in stream of incoming integers
Get K Max and Delete K Max in stream of Incoming Integers
1) Keep a Min & Max Heap of K size 2) Store first K elements
Linked List V/S Binary Search Tree
Linked List :
Node(1) -> Node(2) -> Node(3) -> Node(4) -> Node(5) -> Node(6) -> Node(7)
- In linked list, the items are linked together through a single next pointer.
- Next Node’s Key Can be larger
Doubly linked list
In computer science, a doubly-linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous