[Question]: Given a sorted doubly linked list head. Remove duplicate nodes from the given list. #Approach: Step 1: Compare current node item with next node item Step 2: If two items same move next pointer to next’s nextStep 3: If current Node & next Node doesn’t match use node = next
[Question]: Given a sorted doubly linked list of positive distinct elements, Find pairs in a doubly-linked list whose sum is equal to given value k, without using any extra space? #Approach. Using two pointer
[Question]: Given a doubly linked list and a key x. The problem is to delete all occurrences of the given key x from the doubly linked list. #Approach: we declare two variable prevNode and nxtNode and in a loop if we finds the data value of linklist node is equals to k just break link to the node.
[Question]: Number is represented in linked list such that each digit corresponds to a node in linked list. Add 1 to it. For example 1999 is represented as (1-> 9-> 9 -> 9) and adding 1 to it should change it to (2->0->0->0) #Approach:
[Question]: Given a singly linked list head sort it with with all with zeros, ones and two’sExample:Input: 1 -> 1 -> 2 -> 0 -> 2 -> 0 -> 1 -> NULL Output: 0 -> 0 -> 1 -> 1 -> 1 -> 2 -> 2 -> NULL Approach: Create count array which stores count of 0’s, 1’s …
[Question]: Given Head of singly linked list return a sorted linkedlist head(ascending order.)Criteria: -TC should O(n) SC: O(1) Input: head = [4,2,1,3] Output: [1,2,3,4] #Approach : We can use merge sort: which work on divide & conquer
[Question]: Input singly linked list return true if linked list is palindrome.Example: – Input: head = [1,2,2,1] Output: true Approach# Reverse Linked list & compare first and last item
[Question] Given a Doubly Linked List, the task is to reverse the given Doubly Linked List. Here we can can solve by two approach #1 Iterative #2 Recursive For information about usage visit my Githhub Page
[Question]: Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.
[Question] Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. You must solve the problem in O(1) extra space complexity and O(n) time complexity. Example 1: Input: head = [1,2,3,4,5] Output: [1,3,5,2,4]