All Posts

Leetcode 2095: Delete the Middle Node of a Linked List

You are given the head of a linked list. Your task is to remove the middle node from the linked list and return the modified list. The middle node is defined as the ⌊n / 2⌋th node, where n is the number of nodes in the list, using 0-based indexing.

Leetcode 2130: Maximum Twin Sum of a Linked List

You are given a linked list with an even number of nodes. Each node in the list has a twin located symmetrically from the center of the list. Specifically, the ith node is the twin of the (n-1-i)th node, where n is the total number of nodes in the list. For example, the first node is the twin of the last node, the second node is the twin of the second last node, and so on. The twin sum is defined as the sum of a node and its twin. Your task is to return the maximum twin sum of the linked list.

Leetcode 2181: Merge Nodes in Between Zeros

You are given the head of a linked list where each segment of the list is separated by nodes with the value 0. Merge the nodes between two consecutive 0 nodes and replace them with a single node whose value is the sum of the nodes in between. The list should not contain any 0 nodes.

Leetcode 2326: Spiral Matrix IV

You are given two integers, m and n, which represent the dimensions of a matrix. You are also given the head of a linked list of integers. Your task is to generate an m x n matrix by filling it in a spiral order (clockwise) using the integers from the linked list. If any spaces remain, fill them with -1.

Leetcode 2487: Remove Nodes From Linked List

You are given the head of a linked list. Your task is to remove every node that has a node with a greater value to its right. The modified linked list should be returned after the removal of such nodes.

Leetcode 2807: Insert Greatest Common Divisors in Linked List

You are given the head of a linked list, where each node contains an integer. For each pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor (GCD) of the two nodes. Return the modified linked list after performing this operation.