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 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 50: Pow(x, n)

You are given a number x and an integer n. Your task is to compute x raised to the power n (i.e., x^n). Handle cases where the exponent is negative by returning the reciprocal of the result.

Leetcode 143: Reorder List

You are given the head of a singly linked list. The goal is to reorder the list such that the nodes are arranged as follows: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → …, without modifying the values of the nodes. Only the structure of the list can be changed.

Leetcode 206: Reverse Linked List

Given the head of a singly linked list, reverse the list and return the new head of the reversed list. You need to reverse the order of the nodes in the list such that the first node becomes the last, the second becomes the second to last, and so on.