Combination Sum 2 - Cant Reuse same element

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. Note: The solution set must not contain duplicate combinations. Examples Example 1: Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [ [1,1,6], [1,2,5], [1,7], [2,6] ] ...

Combination Sum 1 Problem

Problem Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different. It is guaranteed that the number of unique combinations that sum up to target is less than 150 combinations for the given input. ...

Permutations of Array 1

Problem Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. OR Given a collection of numbers, return all possible permutations. Examples Example 1: nums = [1,2,3] Output: [ [1,2,3] [1,3,2] [2,1,3] [2,3,1] [3,1,2] [3,2,1] ] ...

Generate All Strings of n bits

Problem Generate All Strings of n bits, consider A[0..n-1] is an array of size n. Examples Example 1 n = 3 Output: [0, 0, 0] [1, 0, 0] [0, 1, 0] [1, 1, 0] [0, 0, 1] [1, 0, 1] [0, 1, 1] [1, 1, 1] ...

Word Search 1 - Find if word exists

Problem Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. Example Example 1: $$ \begin{bmatrix} \color{red} A & \color{red} B & \color{red} C & E \\ S & F & \color{red} C & S \\ A & \color{red} D & \color{red} E & E \end{bmatrix} $$ ...

Word Search 2 - Return All Words

Problem Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. Examples Example 1: ...

Partition Equal Subset Sum Problem

Problem Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Examples Example 1: Input: nums = [1,5,11,5] Output: true Explanation: The array can be partitioned as [1, 5, 5] and [11]. Example 2: Input: nums = [1,2,3,5] Output: false Explanation: The array cannot be partitioned into equal sum subsets. ...

List Combinations - Generate unique combinations from list selecting 1 element from each

Problem Given a list of lists containing elements, write a function that prints out the permutations of of the elements such that, each of the permutation set contains only 1 element from each list and there are no duplicates in the list of permutation sets. Examples Example 1: Input: lists = [ [a1, b1, c1], [a2, b2] ] Output: [ [a1, a2], [a1, b2], [b1, a2], [b1, b2], [c1, a2], [c1, b2] ] Explanation: Note that [a1, a2] is same as [a2, a1] in terms of combination, though they are separate permutation. ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy