Arrays and Strings

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++
This problem asks you to return the sum of the elements in an array of integers. For example, given the input array [1, 2, 3, 4, 5], the output would be 15 (1 + 2 + 3 + 4 + 5 = 15).
About this solution: This solution is correct and solves the problem. The approach is also optimal, as it has a time complexity of O(n).
Dec 01
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 JavaScript
This problem asks us to return the sum of all odd integers in an array. For example, given the array [1, 2, 3, 4, 5], the output would be 9 .
About this solution: This is a great solution! It is very efficient and only iterates through the array once. It also only adds the odd numbers to the sum, which is exactly what the question asks.
Nov 25
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This technical problem deals with finding the sum of all elements in an array. An example input is given as [1, 2, 3, 4] and the expected output is 10.
About this solution: This solution is correct and demonstrates a level of completeness. The approach is straightforward and easy to follow.
Nov 24
Code Problem / Data Structures and Algorithms DifficultyMedium C++
Given an array of n integers, this algorithm finds the maximum sum of any contiguous subarray of the array in O(n) time.
About this solution: The candidate's solution correctly solves the problem and runs in O(n) time. The approach is generally sound, though there is room for improvement in terms of code clarity. In particular, the variable names could be more descriptive and the use of a single loop could be more clearly explained. Overall, though, this is a solid solution.
Nov 22
Code Problem / Data Structures and Algorithms DifficultyMedium C++
This technical problem deals with finding the largest sum of contiguous integers in an array. An example input is given, along with the expected output.
About this solution: The candidate's solution is optimal because it only iterates through the array once. The candidate's approach is also clear and easy to follow.
Nov 21
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
Given a string, this algorithm will find the first non-repeating character in the string and return its index. If no such character exists, it will return -1.
About this solution: The candidate's solution is a good one. It uses a hash table to store the characters and their indices, and then iterates through the string to check if each character is in the hash table. If it is, then the character is a repeating character. If it is not, then the character is a non-repeating character. The candidate then returns the index of the first non-repeating character. This solution is optimal because it is O(n) time complexity and O(n) space complexity.
Nov 21
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 target. There is always a solution, and you can't use the same element twice.
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.
Nov 20