Algorithms

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#
Implement a queue using two stacks. This means that when you enqueue an item, it goes onto one of the stacks, and when you dequeue an item, it comes off of the other stack.
About this solution: The candidate's solution correctly implements a queue using two stacks. However, the code could be more concise. For example, the ShiftStacks method can be simplified. Additionally, the candidate does not provide any comments explaining the code.
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Find the sum of the first n integers in a list.
About this solution: This solution is correct and demonstrates a level of completeness. The approach is also optimal, as it has a time complexity of O(n).
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem is about determining if a given string has all unique characters. An example input would be "abcdefg" and the corresponding output would be "True".
About this solution: The candidate's solution is correct and uses a HashSet, which is an efficient data structure for this problem. The solution is also O(n), which is the best possible time complexity for this problem.
Nov 29
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 reverse the order of a linked list. For example, if the given linked list is 1->2->3->4->5, the output should be 5-> 4->3->2->1.
About this solution: The candidate's solution correctly reverses the nodes in a linked list. The approach is clear and easy to follow.
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This technical problem deals with returning all possible subsets of a given set of distinct integers. For example, if the input is [1,2,3], the output should be all possible subsets of those integers, which are [], [1], [2], [3], [1,2], [1,3], [2,3], and [1,2, 3].
About this solution: This is a good solution. It is recursive and correctly implements the algorithm. It is also optimal in terms of time and space complexity.
Nov 29
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This problem asks you to write a function to reverse a singly linked list in place. The input is a singly linked list, and the output should be the same list, but reversed .
About this solution: The candidate's solution is a good attempt at solving the problem. However, there are a few things that could be improved. First, the candidate does not mention what the input and output of the function are. It is assumed that the input is a singly linked list and the output is the reversed singly linked list. Second, the candidate does not mention any edge cases that need to be considered. For example, what if the linked list is empty? What if the linked list has only one node? Third, the candidate's explanation of the while loop could be more clear. In particular, it is not entirely clear what is happening when the current node is set to the next node. Overall, the candidate's solution is a good attempt at solving the problem. With some clarification, it could be a great solution.
Nov 28
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given a string of parentheses, this function determines whether the string is balanced. A string is balanced if each opening parentheses is matched by a closing parentheses. For example, the input "(())" would return True, while the input "())(" would return False.
About this solution: This is a great solution! The candidate has thought through the problem and has come up with a very efficient solution.
Nov 28