LeetCode - 150 - Reverse Nodes in k-Group

The problem Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then the left-out nodes at the end should remain as they are. You may not alter the values in the list’s nodes, only nodes themselves may be changed. ...

October 1, 2025 · 4 min · Dmytro Chumakov

LeetCode - 150 - N-Queens

The problem The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solution contains a distinct board configuration of the n-queens’ placement, where 'Q' and '.' both indicate a queen and an empty space, respectively. ...

September 26, 2025 · 6 min · Dmytro Chumakov

LeetCode - 150 - Letter Combinations of a Phone Number

The problem Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Examples Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] Input: digits = "" Output: [] Input: digits = "2" Output: ["a","b","c"] Constraints 0 <= digits.length <= 4 digits[i] is a digit in the range [‘2’, ‘9’] Explanation From the description of the problem, we learn that we are given a string with digits from 2-9 and we need to return all possible combinations that the number could represent. ...

September 15, 2025 · 2 min · Dmytro Chumakov

LeetCode - 150 - Palindrome Partitioning

The problem Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitionings of s. A substring is a contiguous non-empty sequence of characters within a string. A palindrome is a string that reads the same forward and backward. Examples Input: s = "aab" Output: [["a","a","b"],["aa","b"]] Input: s = "a" Output: [["a"]] Constraints 1 <= s.length <= 16 s contains only lowercase English letters. Explanation From the description of the problem we learn that we are given string s that we need to partition in a way that all substrings are palindromes. ...

September 12, 2025 · 3 min · Dmytro Chumakov

LeetCode - 150 - Subsets II

The problem Given an integer array nums that may contain duplicates, return all possible subsets (the power set). A subset of an array is a selection of elements (possibly none) of the array. The solution set must not contain duplicate subsets. Return the solution in any order. Examples Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] Input: nums = [0] Output: [[],[0]] Constraints 1 <= nums.length <= 10 -10 <= nums[i] <= 10 Explanation From the description of the problem we learn that we are given nums that contains duplicate values and we need to return subsets without any duplicates. Let’s look at an example with input [1, 2, 2] From the given input: ...

September 9, 2025 · 3 min · Dmytro Chumakov