Arrays

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:
Python / Data Structures DifficultyMedium Python
To find the sum of the elements in a list of integers, simply iterate through the list and add each element to a total.
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.
Nov 21
Python / Data Structures DifficultyMedium Python
Given an array of integers, find the maximum sum of a contiguous subarray. For example, given the array [-2, 1, -3, 4, -1, 2, 1 , -5, 4], the maximum sum of a contiguous subarray is 6 (the sum of the subarray [4, -1, 2, 1]).
About this solution: This is a great solution! The candidate has thought about the problem carefully and has come up with a very elegant solution. The candidate has also provided a clear explanation of how the solution works. Well done!
Nov 20
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
Python / Data Structures DifficultyMedium Python
This problem asks you to return the sum of all the odd integers in an array. For example, if the input array is [1, 2, 3, 4, 5], the output should be 9.
About this solution: This solution is optimal because it uses a generator expression to filter out the even numbers and then sums the odd numbers. This is optimal because it is a one-liner and it is also very readable.
Nov 19
Python / Data Structures DifficultyMedium Python
Given a list of integers, the largest sum of non-adjacent numbers can be found by writing a function. The function will take the list as input and return the largest sum possible.
About this solution: The candidate's solution is correct and solves the problem. The approach is to use a dynamic programming approach, which is a good approach for this problem. The candidate could have been more concise in their solution, but overall the solution is correct and solves the problem.
Nov 19
Python / Data Structures DifficultyMedium Python
To find the sum of integers in an array, simply iterate through the array and add each integer to a total sum.
About this solution: This solution is complete and solves the problem. The approach is straightforward and easy to understand.
Nov 18
Code Problem / Data Structures and Algorithms DifficultyMedium Python
The problem asks for the sum of all elements in an array. An example input is given as [1, 2, 3, 4, 5] and the expected output is 15.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has used the built-in sum function, which is an optimal solution.
Nov 12
Code Problem / Data Structures and Algorithms Python
Given a string consisting of only lowercase letters, this program generates a new string with the same letters in reverse order. For example, an input of "abcdefg" would produce an output of "gfedcba".
About this solution: The candidate's solution is correct and uses the built-in function reversed(). The time and space complexity of the solution is O(n).
Nov 11