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 an array of positive integers and a positive integer s, this function returns the minimal length of a contiguous subarray of which the sum is greater than or equal to s. If there isn 't one, it returns 0 instead.
About this solution: This is a great solution! The candidate has taken the time to include comments explaining what the code is doing, which is always appreciated. The code itself is clean and well-organized.
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 Python
Given an array of n integers, find the contiguous subarray of given length k that has the maximum average value. Output the maximum average value.
About this solution: The candidate's solution correctly finds the maximum average value of a given array and length k. The solution is clear and easy to follow. One potential improvement would be to use the built-in max() and sum() functions rather than creating a custom max_sum function.
Dec 04
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This problem deals with finding the first non-repeating character in a given string. For example, if the input string is "GeeksforGeeks", then the output should be ' f'.
About this solution: The candidate's solution correctly finds the first non-repeating character in a string. The solution uses a hash map to keep track of the number of times each character appears in the string, then loops through the string again to find the first character with a count of 1. One potential improvement to this solution would be to use a LinkedHashMap instead of a regular hash map. This would allow the characters to be iterated over in the order in which they appear in the string, which would make the second loop unnecessary.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given a binary tree, this function checks whether it is symmetrical around its center. For example, the first tree in the input is symmetrical, but the second one is not.
About this solution: The candidate's solution correctly implements a recursive solution to check if a binary tree is symmetric. The approach is sound, and the code is clean and easy to follow.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium Python
This technical problem deals with determining whether or not a given string consisting of only brackets is valid. A string is considered valid if the open brackets are closed by the same type of brackets in the correct order. An empty string is also considered valid.
About this solution: The candidate's solution is correct and uses a stack to keep track of the order of the brackets. The solution is also complete, with tests for all the different cases.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium Python
Given a list of integers, this code problem finds the largest integer in the list. For example, given the input [1, 2, 3, 4, 5], the output would be 5.
About this solution: This is a good solution that demonstrates a level of completeness and solves the problem. The approach is straightforward and easy to understand.
Dec 03
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given an array of n integers, find the contiguous subarray of given length k that has the maximum average value. Output the maximum average value.
About this solution: The candidate's solution is correct and solves the problem. The approach is good, iterating through the array once and keeping track of the sum of the previous k elements. The time complexity is O(n) and the space complexity is O(1).
Dec 03