Problem Statement: You are given a DLL and a value, get the pairs that match the value. Example Example: 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 6 k = 5 Output: ( 2, 3) Solution Method 1: Two pointers Approach Take 2 pointers …
Problem Statement: You are given a linked list, you need to check if it is a palindrome or not Example B -> A -> C -> A -> B True Solution We can solve this problem using different methods. We shall see 2 methods: Method …
Problem Statement: You are given an single LL. You need to fing the middle element. Example Input : 1->2->3->4->5->6 Output : 4 Solution The solution is very simple. We take 2 pointers, Fast and Slow. Fast will move 2 places at a time. Slow …
Problem Statement: You are given an LL, you need to move the last element to the first. Example Input: 1->2->3->4->5 Output: 5->1->2->3->4. Solution The solution is very simple. Traverse till the last node. Then perform below operations: 1. Make the second last as last …