Backtracking Problems
Master backtracking problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 73 problems in this category.
Total Problems: 73
Easy: 3
Medium: 46
Hard: 24
Showing 50 of 73 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Backtracking LeetCode Problems List
- 77. Combinations - Medium - BacktrackingGiven two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. You may return the answer in any order.... Topics: Backtracking
- 79. Word Search - Medium - BacktrackingGiven 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 sequent... Topics: Array, String, Backtracking, Depth-First Search, Matrix
- 46. Permutations - Medium - BacktrackingGiven an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.... Topics: Array, Backtracking
- 17. Letter Combinations of a Phone Number - Medium - BacktrackingGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any... Topics: Hash Table, String, Backtracking
- 39. Combination Sum - Medium - BacktrackingGiven an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen nu... Topics: Array, Backtracking
- 212. Word Search II - Hard - BacktrackingGiven 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 sequentia... Topics: Array, String, Backtracking, Trie, Matrix
- 22. Generate Parentheses - Medium - BacktrackingGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.... Topics: String, Dynamic Programming, Backtracking
- 78. Subsets - Medium - BacktrackingGiven an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu... Topics: Array, Backtracking, Bit Manipulation
- 787. Sliding Puzzle - Hard - BacktrackingOn an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally... Topics: Array, Dynamic Programming, Backtracking, Breadth-First Search, Memoization, Matrix
- 51. N-Queens - Hard - BacktrackingThe 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 al... Topics: Array, Backtracking
- 301. Remove Invalid Parentheses - Hard - BacktrackingGiven a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return a list... Topics: String, Backtracking, Breadth-First Search
- 37. Sudoku Solver - Hard - BacktrackingWrite a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9... Topics: Array, Hash Table, Backtracking, Matrix
- 494. Target Sum - Medium - BacktrackingYou are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before... Topics: Array, Dynamic Programming, Backtracking
- 47. Permutations II - Medium - BacktrackingGiven a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.... Topics: Array, Backtracking, Sorting
- 126. Word Ladder II - Hard - BacktrackingA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk su... Topics: Hash Table, String, Backtracking, Breadth-First Search
- 131. Palindrome Partitioning - Medium - BacktrackingGiven a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.... Topics: String, Dynamic Programming, Backtracking
- 89. Gray Code - Medium - BacktrackingAn n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An intege... Topics: Math, Backtracking, Bit Manipulation
- 140. Word Break II - Hard - BacktrackingGiven a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all ... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization
- 93. Restore IP Addresses - Medium - BacktrackingA valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading z... Topics: String, Backtracking
- 679. 24 Game - Hard - BacktrackingYou are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on... Topics: Array, Math, Backtracking
- 698. Partition to K Equal Sum Subsets - Medium - BacktrackingGiven an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 638. Shopping Offers - Medium - BacktrackingIn LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or mo... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 800. Letter Case Permutation - Medium - BacktrackingGiven a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible str... Topics: String, Backtracking, Bit Manipulation
- 95. Unique Binary Search Trees II - Medium - BacktrackingGiven an integer n, return all the structurally unique BST's (binary search trees), which has exactly n nodes of unique values from 1 to n. Return the... Topics: Dynamic Programming, Backtracking, Tree, Binary Search Tree, Binary Tree
- 40. Combination Sum II - Medium - BacktrackingGiven a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb... Topics: Array, Backtracking
- 52. N-Queens II - Hard - BacktrackingThe 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 th... Topics: Backtracking
- 1188. Brace Expansion II - Hard - BacktrackingUnder the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents. The gram... Topics: String, Backtracking, Stack, Breadth-First Search
- 813. All Paths From Source to Target - Medium - BacktrackingGiven a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any orde... Topics: Backtracking, Depth-First Search, Breadth-First Search, Graph
- 90. Subsets II - Medium - BacktrackingGiven an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subs... Topics: Array, Backtracking, Bit Manipulation
- 1022. Unique Paths III - Hard - BacktrackingYou are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 repre... Topics: Array, Backtracking, Bit Manipulation, Matrix
- 1825. Find Minimum Time to Finish All Jobs - Hard - BacktrackingYou are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job. There are k workers that you can assign job... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 691. Stickers to Spell Word - Hard - BacktrackingWe are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cu... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 526. Beautiful Arrangement - Medium - BacktrackingSuppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2279. Maximum Split of Positive Even Integers - Medium - BacktrackingYou are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers. For example, given finalSum = 12, the fol... Topics: Math, Backtracking, Greedy
- 2078. Maximum Compatibility Score Sum - Medium - BacktrackingThere is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes). The survey was given to m students numbered f... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1993. Sum of All Subset XOR Totals - Easy - BacktrackingThe XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of the array [2,5,... Topics: Array, Math, Backtracking, Bit Manipulation, Combinatorics, Enumeration
- 257. Binary Tree Paths - Easy - BacktrackingGiven the root of a binary tree, return all root-to-leaf paths in any order. A leaf is a node with no children.... Topics: String, Backtracking, Tree, Depth-First Search, Binary Tree
- 357. Count Numbers with Unique Digits - Medium - BacktrackingGiven an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.... Topics: Math, Dynamic Programming, Backtracking
- 1360. Maximum Length of a Concatenated String with Unique Characters - Medium - BacktrackingYou are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximu... Topics: Array, String, Backtracking, Bit Manipulation
- 2170. Count Number of Maximum Bitwise-OR Subsets - Medium - BacktrackingGiven an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the ma... Topics: Array, Backtracking, Bit Manipulation, Enumeration
- 473. Matchsticks to Square - Medium - BacktrackingYou are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one s... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1516. The k-th Lexicographical String of All Happy Strings of Length n - Medium - BacktrackingA happy string is a string that: consists only of letters of the set ['a', 'b', 'c']. s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (str... Topics: String, Backtracking
- 1900. Closest Dessert Cost - Medium - BacktrackingYou would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You... Topics: Array, Dynamic Programming, Backtracking
- 1160. Letter Tile Possibilities - Medium - BacktrackingYou have n tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make us... Topics: Hash Table, String, Backtracking, Counting
- 113. Path Sum II - Medium - BacktrackingGiven the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum.... Topics: Backtracking, Tree, Depth-First Search, Binary Tree
- 216. Combination Sum III - Medium - BacktrackingFind all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number ... Topics: Array, Backtracking
- 306. Additive Number - Medium - BacktrackingAn additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for... Topics: String, Backtracking
- 2140. Longest Subsequence Repeated k Times - Hard - BacktrackingYou are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s. A subsequence is ... Topics: String, Backtracking, Greedy, Counting, Enumeration
- 1030. Smallest String Starting From Leaf - Medium - BacktrackingYou are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographic... Topics: String, Backtracking, Tree, Depth-First Search, Binary Tree
- 2189. Maximum Path Quality of a Graph - Hard - BacktrackingThere is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the ... Topics: Array, Backtracking, Graph
- 1429. Verbal Arithmetic Puzzle - Hard - BacktrackingGiven an equation, represented by words on the left side and the result on the right side. You need to check if the equation is solvable under the fol... Topics: Array, Math, String, Backtracking
- 3649. Minimum Time to Break Locks I - Medium - BacktrackingBob is stuck in a dungeon and must break n locks, each requiring some amount of energy to break. The required energy for each lock is stored in an arr... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Depth-First Search, Bitmask
- 2166. Number of Valid Move Combinations On Chessboard - Hard - BacktrackingThere is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describ... Topics: Array, String, Backtracking, Simulation
- 401. Binary Watch - Easy - BacktrackingA binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a ze... Topics: Backtracking, Bit Manipulation
- 1038. Number of Squareful Arrays - Hard - BacktrackingAn array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutation... Topics: Array, Hash Table, Math, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 491. Non-decreasing Subsequences - Medium - BacktrackingGiven an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may retu... Topics: Array, Hash Table, Backtracking, Bit Manipulation
- 2114. Minimum Number of Work Sessions to Finish the Tasks - Medium - BacktrackingThere are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to fi... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 282. Expression Add Operators - Hard - BacktrackingGiven a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' betwe... Topics: Math, String, Backtracking
- 2754. Maximum Strength of a Group - Medium - BacktrackingYou are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of stud... Topics: Array, Dynamic Programming, Backtracking, Greedy, Bit Manipulation, Sorting, Enumeration
- 3951. Next Special Palindrome Number - Hard - BacktrackingYou are given an integer n. A number is called special if: It is a palindrome. Every digit k in the number appears exactly k times. Return the smalles... Topics: Backtracking
- 1723. Maximum Number of Achievable Transfer Requests - Hard - BacktrackingWe have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the bui... Topics: Array, Backtracking, Bit Manipulation, Enumeration
- 2174. Next Greater Numerically Balanced Number - Medium - BacktrackingAn integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x. Given an integer n, ret... Topics: Hash Table, Math, Backtracking, Counting, Enumeration
- 986. Largest Time for Given Digits - Medium - BacktrackingGiven an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once. 24-hour times are formatted as "HH:MM", w... Topics: Array, String, Backtracking, Enumeration
- 1381. Maximum Score Words Formed by Letters - Hard - BacktrackingGiven a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words f... Topics: Array, String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2696. The Number of Beautiful Subsets - Medium - BacktrackingYou are given an array nums of positive integers and a positive integer k. A subset of nums is beautiful if it does not contain two integers with an a... Topics: Array, Hash Table, Math, Dynamic Programming, Backtracking, Sorting, Combinatorics
- 1361. Tiling a Rectangle with the Fewest Squares - Hard - BacktrackingGiven a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.... Topics: Backtracking
- 872. Split Array into Fibonacci Sequence - Medium - BacktrackingYou are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like ... Topics: String, Backtracking
- 1577. Probability of a Two Boxes Having The Same Number of Distinct Balls - Hard - BacktrackingGiven 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i. All the ball... Topics: Array, Math, Dynamic Programming, Backtracking, Combinatorics, Probability and Statistics
- 3453. Generate Binary Strings Without Adjacent Zeros - Medium - BacktrackingYou are given a positive integer n. A binary string x is valid if all substrings of x of length 2 contain at least one "1". Return all valid strings w... Topics: String, Backtracking, Bit Manipulation
- 2130. Maximum Product of the Length of Two Palindromic Subsequences - Medium - BacktrackingGiven a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoi... Topics: String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 1331. Path with Maximum Gold - Medium - BacktrackingIn a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the ma... Topics: Array, Backtracking, Matrix
- 1418. Fair Distribution of Cookies - Medium - BacktrackingYou are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes th... Topics: Array, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2107. Find Unique Binary String - Medium - BacktrackingGiven an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. I... Topics: Array, Hash Table, String, Backtracking
Related LeetCode Topics
- Array LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems
- Divide and Conquer LeetCode Problems