## Binary Search

#### Recent solutions:

Check these solutions from our community:
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This problem deals with determining if a given value is present in a sorted array. An example input is given as [1, 3, 5, 7], 5, with the expected output being true.
About this solution: The candidate's solution is correct and demonstrates a level of completeness. The candidate has correctly identified that the optimal solution is to use a binary search algorithm, and has correctly implemented a recursive binary search algorithm. The candidate's solution correctly returns true when the value is found in the array, and correctly returns false when the value is not found in the array.
Dec 11
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem deals with finding a target value in a sorted array using binary search. If the target value is found in the array, the index of that value is returned. If the target value is not found in the array, -1 is returned.
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The general approach is not clear.
Dec 09
Code Problem / Data Structures and Algorithms DifficultyMedium C#
This problem deals with implementing a binary search algorithm to find the index of a given target value in a sorted array. If the target is not found, the function should return -1.
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The general approach is not clear.
Dec 08
Code Problem / Data Structures and Algorithms DifficultyMedium C++
The problem is to find the index of a given target value in a sorted array of integers, using the binary search algorithm. If the target value is not present in the array, the function should return -1.
About this solution: The candidate's solution is complete and solves the problem. The candidate has used a binary search algorithm, which is a common and efficient approach to solving this problem.
Dec 07
Code Problem / Data Structures and Algorithms DifficultyMedium JavaScript
This problem deals with finding the index of an element in a sorted array of integers. The input is a sorted array of integers and an integer value to find. The output is the index of the value in the array, or -1 if the value is not present in the array.
About this solution: The candidate's solution is correct and uses binary search, which is the most efficient way to search a sorted array for a specific value. The candidate's code is well-written and easy to understand.
Dec 07
Code Problem / Data Structures and Algorithms DifficultyMedium C#
Given a list of integers, write a function that returns the index of the first integer that is greater than or equal to the given target. If there is no such integer, return -1 .
About this solution: The candidate's solution correctly finds the index of the first integer that is greater than or equal to the given target. However, the code could be more concise. For example, the candidate could use a for-each loop instead of a for loop. In addition, the candidate could use the Array.FindIndex method instead of writing their own loop.
Dec 02
Code Problem / Data Structures and Algorithms DifficultyMedium C#
Given a list of numbers, the function will return the index of the number if it exists in the list. If it does not exist, the function will return -1.
About this solution: The candidate's solution correctly solves the problem. However, it is not the most efficient solution. A more efficient solution would be to use a binary search algorithm, which would run in O(log n) time.
Dec 02
Code Problem / Data Structures and Algorithms DifficultyMedium C#
The problem asks you to implement a binary search function that takes in a sorted array of integers and a target integer. The function should return the index of the target integer if it is found in the array, or -1 if it is not found.
About this solution: The candidate's solution does not demonstrate a level of completeness and does not solve the problem. The candidate's approach is not clear.
Nov 30