# Linked List

### Form a Rectangle from boundary elements of Matrix using Linked List

class Node:          def __init__(self, val):        self.data = val        self.next = None        self.prev = None        self.top = None        self.bottom = None    class LinkedList:          def __init__(self):        self.head = None              def Quad(self, grid,…

Read More

### Reverse a singly Linked List in groups of given size | Set 4 (Space efficient approach)

class LinkedList {          Node head;          class Node {        int data;        Node next;        Node(int d)        {            data = d;            next = null;        }    }      Node reverse(Node node, int k)    {        if (k == 1)            return…

Read More

### Multiply a single digit number in place to a number represented as a Linked List

#include using namespace std;  class Node {public:    int data;    Node* next;};  Node* newNode(int data){        Node* new_node = new Node;          new_node->data = data;    new_node->next = NULL;          return new_node;}  Node* reverse(Node*…

Read More

### Partition a Linked List into 3 parts such that the maximum difference between their sizes is minimum

#include using namespace std;  class Node {public:    int data;    Node* next;};  int sizeOfLL(Node* head){    int size = 0;          while (head != NULL) {        ++size;        head = head->next;    }    return size;}  vector…

Read More

### Modify a Linked List to contain last occurrences of every duplicate element

#include using namespace std;  class Node {public:    int data;    Node* next;      Node(int x)    {        this->data = x;        this->next = NULL;    }};  Node* reverseList(Node* head){    Node *prev = NULL, *nextNode =…

Read More

### Subtract 1 from a number represented as Linked List

#include using namespace std;  class Node {public:    int data;    Node* next;};  Node* newNode(int data){        Node* new_node = new Node;    new_node->data = data;    new_node->next = NULL;          return new_node;}  int subtractOneUtil(Node*…

Read More

### Find quadruplets with given sum in a Doubly Linked List

#include using namespace std;  struct Node {    int data;    struct Node *next, *prev;};  void insert(struct Node** head, int data){        struct Node* temp = new Node();          temp->data…

Read More

### Partition a Linked List into K continuous groups with difference in their sizes at most 1

#include using namespace std;  struct ListNode {    int val;    struct ListNode* next;};  void push(ListNode** head_ref,          int node_val){        ListNode* new_node = new ListNode();          new_node->val = node_val;          new_node->next = (*head_ref);          (*head_ref)…

Read More