## Code Problem / Data Structures and Algorithms / Recursion

#### Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem asks you to find the maximum path sum from the root to a leaf in a binary tree. An example input and output are given.
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The approach is not clear.
Nov 28
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Print the power set of a set of distinct integers. The power set of a set is the set of all its subsets.
About this solution: The candidate's solution is complete and solves the problem. The approach is to use bitwise operators to generate all possible subsets. This is a clever approach that demonstrates a good understanding of bitwise operators.
Nov 27
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem is about printing all numbers from 1 to n in ascending order. The function takes in a number n and prints out all numbers from 1 to n.
About this solution: The candidate's solution correctly prints out all the numbers from 1 to n in ascending order. The candidate's approach is to use a for loop to iterate through the numbers from 1 to n and print each number. This is a valid approach.
Nov 27
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem deals with printing the power set of a given set of distinct integers. The power set is the set of all subsets of a given set, including the empty set and the original set itself. In this case, the input is {1, 2, 3} and the output should be {{}, {1}, {2}, {3}, {1, 2}, {1 , 3}, {2, 3}, {1, 2, 3}}.
About this solution: The candidate's solution correctly generates the power set of a given set of distinct integers. The solution is complete and correctly solves the problem. The approach is straightforward and easy to follow.
Nov 27
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem asks the programmer to find the sum of all elements in an array. An example input is given, along with the expected output.
About this solution: The candidate's solution is correct and uses an optimal approach. The time complexity of the solution is O(n).
Nov 26
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given a string, the goal is to find the length of the longest substring without repeating characters. For example, given the string "abcabcbb", the longest substring would be " abc", with a length of 3.
About this solution: The candidate's solution correctly finds the length of the longest substring without repeating characters. The solution uses a hash map to keep track of the last seen index of each character. If a character is seen again, the candidate checks if the character was seen after the start of the current substring. If so, the candidate updates the start of the substring to be one character after the last seen index of the repeated character. Otherwise, the candidate simply increments the length of the current substring. The candidate's solution correctly handles all edge cases and runs in O(n) time.
Nov 25
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
The problem is to find the sum of all elements in an array using recursion.
About this solution: The candidate's solution is correct and uses the reduce method to sum all elements in the array. The candidate's solution is clear and concise.
Nov 22
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given a set of distinct integers, this problem returns all possible subsets that can be formed from those integers. For example, if the input is [1,2,3], the output would 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 approach is to use a backtracking algorithm to generate all possible subsets.
Nov 22