Backtracking

Categories: Code Problem / Data Structures and Algorithms / Recursion (32) Code Problem / Data Structures and Algorithms / Binary Search (30) Code Problem / Data Structures and Algorithms / Linked Lists (26) Code Problem / Data Structures and Algorithms / Backtracking (26) Code Problem / Data Structures and Algorithms / Stacks and Queues (25) Code Problem / Data Structures and Algorithms / Hashing (24) Databases / SQL / Backup and Recovery (19) Code Problem / Data Structures and Algorithms / Arrays and Strings (19) Databases / SQL / Database Normalization (18) Code Problem / Data Structures and Algorithms / Time Complexity (17) Databases / SQL / Locking (16) Databases / SQL / Replication (15) Databases / SQL / SQL Queries (13) Code Problem / Data Structures and Algorithms / Graphs (13) Databases / SQL / Database Security (13)  More...

Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem deals with finding all possible subsets of a set of distinct integers. The elements in each subset must be in non-descending order, and the solution set must not contain duplicate subsets.
About this solution: The candidate's solution is complete and solves the problem. The approach is to use a backtracking algorithm to generate all possible subsets.
Dec 05
Code Problem / Data Structures and Algorithms DifficultyMedium C#
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers. The first two numbers in the sequence are 1 and 1, and the third number is 2. The fourth number is 3, the fifth number is 5, and so on. The function takes in a number n and prints out the first n numbers of the Fibonacci sequence .
About this solution: The candidate's solution does not print out the first n numbers of the Fibonacci sequence as requested. The solution is incomplete and does not solve the problem. The candidate's approach is not clear.
Dec 04
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Find the minimum path sum in a 2D array from the top-left corner to the bottom-right corner.
About this solution: The candidate's solution correctly solves the problem and uses a dynamic programming approach. The code is well-written and easy to follow.
Dec 04
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem asks us to find all the words in a 2D array of characters. The input is a 2D array of characters, and the output is a list of strings containing all the words in the array.
About this solution: The candidate's solution correctly solves the problem. The candidate uses a StringBuilder to construct the words from the 2D array, which is a good approach. The candidate's code is also clean and easy to read.
Dec 02
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given a set of distinct integers, this algorithm will return all possible permutations of those integers. For example, if the input is [1,2,3], the algorithm will return [[ 1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]].
About this solution: This solution is complete and solves the problem. The approach is to generate all permutations by iterating through the list of numbers and recursively generating all permutations of the sublist without the current number. This is then added to the list of permutations.
Nov 30
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem asks you to generate all possible subsets of a given set of distinct integers. For example, if the input is [1,2,3], the output should list all possible subsets: [1], [1,2], [1,2,3], [1,3], [2], [2,3], and [3].
About this solution: The candidate's solution is complete and solves the problem. The approach is to first create an empty subset, and then add each element of the given set to all existing subsets to create new subsets. This is a valid approach to solving the problem.
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem asks you to generate all possible subsets from a set of distinct integers. For example, given the input [1,2,3], the output should be [[3],[1 ],[2],[1,2,3],[1,3],[2,3],[1,2],[]]
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to first add the empty subset to the result, and then iterate through the numbers in the input array. For each number, the candidate loops through all the subsets in the result and adds the number to create a new subset. This approach is correct.
Nov 28
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given a string of digits, this problem seeks to find all possible valid IP addresses that could be generated from it. IP addresses are typically represented in dot-decimal notation (e.g . "192.168.1.1"), so the goal is to find all possible ways to group the digits in the input string into sets of four that could each correspond to one section of an IP address.
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to generate all possible IP addresses and check if they are valid.
Nov 27