PROBLEM DESCRIPTION Given an array arr[ ] of n elements, the task is to find the next greater element for each element of the array in order of their appearance in the array. Next greater element ...
Queue using two Stacks (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Implement a Queue using 2 stacks s1 and s2 A Query Q is of 2 Types (i) 1 x (a query of this type means pushing ‘x’ into the queue) (ii) 2 (a query of this type means to pop e...
Stack using two queues (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Implement a Stack using two queues q1 and q2. geeksforgeeks SOLUTION push: add current element to q2 transfer all elements from q1 to q2 switch q1, q2 reference...
Binary Tree to DLL (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given a Binary Tree (BT), convert it to a Doubly Linked List (DLL) in place. The left and right pointers in nodes will be used as previous and next pointers respectively in con...
Reverse a Linked List in Groups (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given a linked list, the task is to reverse every k node (where k is an input to the function) in the linked list. If the number of nodes is not a multiple of k then left-out n...
Merge K sorted linked lists (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given an array of sorted linked lists of different sizes. The task is to merge them in such a way that after merging they will be a single sorted linked list. geeksforgeeks S...
Merge two sorted linked lists (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given two sorted linked lists consisting of nodes respectively. The task is to merge both lists and return the head of the merged list. geeksforgeeks SOLUTION class Solution...
Flattening a Linked List (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given a Linked List, where every node represents a sub-linked-list and contains two pointers: (i) a next pointer to the next node, (ii) a bottom pointer to a linked list where ...
Rotate a Linked List (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given the head of a singly linked list, the task is to rotate the left shift of the linked list by k nodes, where k is a given positive integer smaller than or equal to the len...
Intersection Point in Y Shaped Linked Lists (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given two singly linked lists, return the point where two linked lists intersect. Note: If the linked lists do not merge at any point, return -1. geeksforgeeks SOLUTION We ...