All Posts

Leetcode 2: Add Two Numbers

You are given two linked lists representing two non-negative integers, where each node contains a single digit, and the digits are stored in reverse order. Your task is to add these two numbers and return the result as a linked list. You can assume that the input does not contain leading zeros except for the number 0 itself.

Leetcode 19: Remove Nth Node From End of List

You are given the head of a singly linked list. Your task is to remove the nth node from the end of the list and return the updated list.

Leetcode 21: Merge Two Sorted Lists

Given two sorted linked lists, merge them into one sorted linked list by splicing together the nodes from both lists. Return the head of the merged linked list.

Leetcode 24: Swap Nodes in Pairs

You are given the head of a singly linked list. Your task is to swap every two adjacent nodes in the list and return its head. The nodes themselves should be swapped, not just the values.

Leetcode 86: Partition List

Given the head of a linked list and a value x, partition the list such that all nodes with values less than x appear before nodes with values greater than or equal to x. The relative order of the nodes in each partition should be preserved.

Leetcode 92: Reverse Linked List II

Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the linked list starting at position left and ending at position right. Return the modified linked list.