Easy58.1% acceptance
Binary Search
Find the target value in a sorted array using binary search.
Topics
Binary SearchArrays
Examples
Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
Input: nums = [-1,0,3,5,9,12], target = 2
Output: -1
Expected Complexity
O(log n) time and O(1) space.
What happens after Submit?
ERROR DNA analyzes your submission and identifies recurring patterns in your mistakes.
solution.cppC++17
Loading...
C++17