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 JavaScript
This problem is about reversing a linked list. Given a linked list, the goal is to reverse the order of the nodes in the list. For example, if the input list is 1 -> 2 -> 3 -> 4 -> 5, the output should be 5 -> 4 -> 3 -> 2 -> 1.
About this solution: The candidate's solution is correct and uses a stack to reverse the order of the nodes in the list. The time complexity of the solution is O(n) and the space complexity is O(n).
Nov 19
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given an array of integers, this problem aims to find the length of the longest increasing subsequence in the array. For example, given the array [10,9,2,5, 3,7,101,18], the longest increasing subsequence is [2,3,7,101] and the length is 4.
About this solution: The candidate's solution is correct and solves the problem. The approach is to use dynamic programming. The idea is to create a list of the same length as the input list. The list will contain the length of the longest increasing subsequence ending at the index of the input list. The list will be filled in a bottom-up manner. The base case is when the list is empty. The length of the longest increasing subsequence ending at the first index is 1. The length of the longest increasing subsequence ending at the second index is 1. The length of the longest increasing subsequence ending at the third index is 1. The length of the longest increasing subsequence ending at the fourth index is 2. The length of the longest increasing subsequence ending at the fifth index is 2. The length of the longest increasing subsequence ending at the sixth index is 3. The length of the longest increasing subsequence ending at the seventh index is 4. The length of the longest increasing subsequence ending at the eighth index is 4. The solution is the maximum value in the list. The time complexity is O(n^2) and the space complexity is O(n).
Nov 19
Code Problem / Data Structures and Algorithms DifficultyMedium Python
The "Maximum Subarray Sum" problem asks us to find the contiguous subarray within an array of numbers that has the largest sum. For example, given the array [-1, 3, -5, 4, 6], the largest sum would be 11, achieved by taking the subarray [3, -5, 4, 6].
About this solution: The candidate's solution correctly finds the maximum sum of a contiguous subarray. The approach is to keep track of the current sum and update the maximum sum if the current sum is greater than the maximum sum. If the current sum is negative, then the current sum is reset to 0.
Nov 19
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem deals with finding a route between two nodes in a directed graph. An example input is given, along with the expected output.
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 19
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem asks you to reverse a singly linked list. An example input is given as 1->2->3->4->5, and the expected output is 5->4->3 ->2->1.
About this solution: This solution is complete and solves the problem. The approach is to reverse the linked list by changing the next pointers of each node. The solution first sets the next pointer of the head node to NULL, then iterates through the linked list, setting the next pointer of each node to the previous node, and finally returns the previous node (which is the new head of the reversed linked list).
Nov 19
Code Problem / Data Structures and Algorithms DifficultyHard C++
This problem asks you to reverse the order of a singly linked list. For example, if the input 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 order of a singly linked list. The approach is clear and easy to follow.
Nov 18
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks for the implementation of a hash table in Java. The input is a set of keys to be stored in the hash table, and the output is the hash table containing the keys .
About this solution: The candidate's solution is correct and uses an efficient data structure (a dictionary) to implement the hash table.
Nov 18
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This problem asks you to write a function that takes in the head node of a singly linked list and a value, and returns the node with the given value. If the value is not present in the linked list, return null.
About this solution: The candidate's solution correctly implements a function to find a node in a singly linked list by its value. The candidate's use of a while loop to iterate through the list is an efficient way to find the desired node. The candidate's solution is optimal in that it correctly implements the function and efficiently iterates through the list.
Nov 18