Hashing

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 list of positive integers, this algorithm finds the two integers that have the largest product.
About this solution: The candidate's solution is optimal because it only iterates through the vector once. However, the candidate does not provide a detailed explanation of their approach, which makes it difficult to understand their thought process. In addition, the candidate does not comment on their code, which makes it difficult to follow.
Dec 11
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given an array of integers and a target value, return the indices of the two array elements that add up to the target value. Assume that each input will have only one solution, and that the same array element cannot be used twice.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate's approach is also correct, using a hash table to store the numbers and their indices. This solution is optimal because it is O(n) time complexity and O(n) space complexity.
Dec 10
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This function takes in a set of integers and a target value, and returns true if there is a pair of integers in the set that sum up to the target value. Otherwise, it returns false.
About this solution: The candidate's solution is complete and solves the problem. The approach is to use a hash map to store the complement of each number in the array. If the complement exists in the hash map, then a pair exists that sums up to the target value.
Dec 09
Code Problem / Data Structures and Algorithms DifficultyMedium Python
The function should return the sum of the integers that are hashed to odd values.
About this solution: The candidate's solution is optimal because it uses a generator expression to iterate over the list and sum only the values that hash to odd values. This is optimal because it is a single pass over the list and uses a generator expression to avoid creating a new list.
Dec 09
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given an array of integers and a target sum, return the indices of the two numbers that add up to the target sum.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has correctly identified the problem and has provided a solution that solves the problem. The candidate's approach is general and could be applied to similar problems.
Dec 08
Code Problem / Data Structures and Algorithms DifficultyMedium C++
The problem is to find the indices of two numbers in an array that add up to a specific target. For example, given an array of numbers and a target of 9, the indices of the two numbers that add up to 9 would be returned.
About this solution: The candidate's solution is complete and solves the problem. The approach is to use a hash map to store the elements of the array and their corresponding indices. Then, for each element in the array, the candidate checks if the hash map contains an element that is equal to the target minus the current element. If such an element is found, then the candidate returns the indices of the two elements. Otherwise, the candidate adds the current element to the hash map.
Dec 08
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
The "two sum problem" is a classic problem in computer science that involves finding two numbers in an array that add up to a given target. This problem can be solved using a simple brute -force approach, but more efficient solutions exist, such as using a hash table.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has correctly identified the problem and has provided a solution that solves the problem. The candidate's approach is general and could be applied to similar problems.
Dec 02
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given an array of integers and a target value, this problem asks if there is a pair of integers in the array that sums to the target value. An example input and output are given.
About this solution: The candidate's solution is complete and solves the problem. The candidate has used a hash map to store the complement of each number in the array. If the complement exists in the hash map, then the candidate returns true. Otherwise, the candidate adds the current number and its index to the hash map.
Dec 01