Linked List

- Blogathon, Blogathon-2021, Geometric, Linked List, Mathematical, Matrix, square-rectangle

Form a Rectangle from boundary elements of Matrix using Linked List

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

Read More

- Linked List, Reverse

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

- Linked List, Linked Lists, Mathematical, partition

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