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

LeetCode - 150 - Permutations

The problem Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. A permutation is a rearrangement of all the elements of an array. Examples Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Input: nums = [0,1] Output: [[0,1],[1,0]] Input: nums = [1] Output: [[1]] Constraints 1 <= nums.length <= 6 -10 <= nums[i] <= 10 All the integers of nums are unique. Explanation From the description of the problem we learn that we need to return all possible permutations from an array of distinct integer values. ...

September 6, 2025 · 3 min · Dmytro Chumakov

LeetCode - 150 - Combination Sum II

The problem Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used once in the combination. The solution set must not contain duplicate combinations. Examples Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [ [1,1,6], [1,2,5], [1,7], [2,6] ] Input: candidates = [2,5,2,1,2], target = 5 Output: [ [1,2,2], [5] ] Constraints 1 <= candidates.length <= 100 1 <= candidates[i] <= 50 1 <= target <= 30 Explanation From the description of the problem, we learn that we are given an array of numbers candidates and we want to find every combination that will sum to the given target. ...

September 2, 2025 · 4 min · Dmytro Chumakov

LeetCode - 150 - Subsets

The problem Given an integer array nums of unique elements, 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,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Input: nums = [0] Output: [[],[0]] Constraints 1 <= nums.length <= 10 -10 <= nums[i] <= 10 All the numbers of nums are unique. Explanation From the description of the problem we learn that we need to return every single subset that we can create from input nums, without any duplicates. ...

August 27, 2025 · 3 min · Dmytro Chumakov