All Posts

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 89: Gray Code

Given an integer n, generate an n-bit Gray code sequence. A Gray code sequence is a sequence of integers where each integer’s binary representation differs from the next one by exactly one bit. The first integer in the sequence is always 0, and every integer appears only once in the sequence. The binary representation of the first and last integers should also differ by exactly one bit.

Leetcode 90: Subsets II

Given an integer array nums that may contain duplicates, return all possible subsets (the power set) of the array. The solution set should not contain duplicate subsets. The subsets should be returned in any order.

Leetcode 91: Decode Ways

You have intercepted a string of numbers that encodes a message. The message is decoded using the following mapping:

“1” -> ‘A’, “2” -> ‘B’, … “26” -> ‘Z’.

However, there are multiple ways to decode the string, as some numbers can represent a single letter (e.g., ‘1’ for ‘A’, ‘12’ for ‘L’). Your task is to return the number of possible ways to decode the string. Note that strings containing invalid encodings (e.g., starting with zero or having codes larger than 26) should not be considered valid.

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.

Leetcode 95: Unique Binary Search Trees II

Given an integer n, return all structurally unique binary search trees (BSTs) that can be constructed using the integers from 1 to n. Each tree should be a unique arrangement of nodes where each node contains a unique value from the set {1, 2, …, n}.