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++
Given a singly linked list, this function returns the middle node of the list. If the list has an even number of nodes, the function returns the node at the start of the second half of the list.
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to create a linked list from the given vector data, print the list, and then find the middle node of the list.
Dec 05
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 Python
This problem asks you to reverse a string using a stack. An example input and output is provided.
About this solution: This is a good solution that uses a stack to reverse the string. The stack is a LIFO data structure, so the last character in the string will be the first character in the stack. The first character in the string will be the last character in the stack. The stack will be popped until it is empty, and the characters will be added to a new string. The new string will be the reversed string.
Dec 05
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This technical problem deals with how to print all possible permutations of a given string using recursion. For example, if the input string is "abc", the output would be all six possible permutations of the string: "abc", "acb", "bac", "bca", "cab", and "cba".
About this solution: This is a good solution that uses recursion to generate all permutations of a given string. The time complexity of this solution is O(n!), which is optimal.
Dec 05
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given an array of integers, this problem aims to find the length of the longest increasing subsequence in the array. For example, given the input array [10, 9, 2, 5 , 3, 7, 101, 18], the output should be 4, as the longest increasing subsequence in the array is [2, 3, 7, 101]. This problem can be solved using dynamic programming, and the time complexity of the solution is O(n^2).
About this solution: The candidate's solution is correct and uses dynamic programming to solve the problem. However, the solution is not very efficient because it uses two for loops.
Dec 05
Code Problem / Data Structures and Algorithms DifficultyMedium C#
Find the first non-repeating character in a given string.
About this solution: The candidate's solution correctly solves the problem and uses a reasonable approach.
Dec 04
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
A stack is a data structure that supports push, pop, and min operations in constant time.
About this solution: The candidate's solution is complete and solves the problem. The candidate's approach is to use a second stack to keep track of the minimum value. When a new value is pushed onto the stack, it is also pushed onto the min stack if it is less than or equal to the current min value. When a value is popped off the stack, it is also popped off the min stack if it is equal to the current min value. This way, the min stack will always have the current min value at the top. This solution is optimal because it allows for constant time min operations.
Dec 04
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