Recursion and Backtracking
47 problems to practice.
Permutation - 1
1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are r...
Combinations - 1
1. You are give a number of boxes (nboxes) and number of identical items (ritems). 2. You are requi...
Permutations - 2
1. You are give a number of boxes (nboxes) and number of non-identical items (ritems). 2. You are r...
Combinations - 2
1. You are give a number of boxes (nboxes) and number of identical items (ritems). 2. You are requi...
Permutations - Words - 1
1. You are given a word (may have one character repeat more than once). 2. You are required to gene...
Permutations - Words - 2
1. You are given a word (may have one character repeat more than once). 2. You are required to gen...
Words - K Selection - 1
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Selection - 2
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Length Words - 1
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Length Words - 2
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Selection - 3
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Selection - 4
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Length Words - 3
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Words - K Length Words - 4
1. You are given a word (may have one character repeat more than once). 2. You are given an integer...
Coin Change - Combinations - 1
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Coin Change - Combinations - 2
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Coin Change - Permutations - 1
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Coin Change - Permutations - 2
1. You are given a number n, representing the count of coins. 2. You are given n numbers, represent...
Queens Combinations - 2d As 2d - Box Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Queens Permutations - 2d As 2d - Queen Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Queens Permutations - 2d As 2d - Box Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Queens Combinations - 2d As 2d - Queen Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Queens Combinations - 2d As 1d - Queen Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Nqueens Combinations - 2d As 1d - Queen Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Nknights Combinations - 2d As 1d - Knight Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Friends Pairing - 2
1. You are given an integer n, which represents n friends numbered from 1 to n. 2. Each one can rem...
K-partitions
1. You are given two integers n and k, where n represents number of elements and k represents...
All Palindromic Permutations
1. You are given a string of length n. 2. You have to print all the palindromic permutations of the...
All Palindromic Partitions
1. You are given a string of length n. 2. You have to partition the given string in such a way that...
K Subsets With Equal Sum
1. You are given an array of n distinct integers. 2. You have to divide these n integers into k non...
Tug Of War
1. You are given an array of n integers. 2. You have to divide these n integers into 2 subsets such...
Pattern Matching
1. You are given a string and a pattern. 2. You've to check if the string is of the same structure...
Word Break - I
1. You are given n space separated strings, which represents a dictionary of words. 2. You are give...
Remove Invalid Parenthesis
1. You are given a string, which represents an expression having only opening and closing parenthesi...
Largest Number Possible After At Most K Swaps
1. You are given a string which represents digits of a number. 2. You have to create the maximum nu...
Gold Mine - 2
1. You are given a number n, representing the number of rows. 2. You are given a number m, represen...
Solve Sudoku
1. You are give a partially filled 9*9 2-D array(arr) which represents an incomplete sudoku state....
Crossword Puzzle
1. You are given a 10*10 2-D array(arr) containing only '+' and '-' characters, which represents a...
Cryptarithmetic
1. You are given three strings s1, s2 and s3. 2. First two are supposed to add and form third. s1 +...
Magnets
1. You are given n number of domino shaped bipolar magnets. 2. You have to place these magnets in M...
Lexicographical Numbers
1. You are given a number. 2. You have to print all the numbers from 1 to n in lexicographical orde...
Josephus Problem
1. You are given two numbers N and K. 2. N represents the total number of soldiers standing in a ci...
Max Score
1. You are given a list of words, a list of alphabets(might be repeating) and score of every alphabe...
N Queens - Branch And Bound
1. You are given a number n, the size of a chess board. 2. You are required to place n number of qu...
Abbreviation Using Backtracking
1. You are given a word. 2. You have to generate all abbrevations of that word. Use recursion as...
Nqueens Permutations - 2d As 1d - Queen Chooses
1. You are given a number n, representing the size of a n * n chess board. 2. You are required to c...
Restore Ip Addresses
https://leetcode.com/problems/restore-ip-addresses/