In this video lesson we will learn about the concept of searching, linear searching and more important - Binary Searching:
Problem:
Given a sorted array of integers nums, use Binary Search to find and return the index of a given value.
If the value doesn't exist in nums, return -1.
Example 1:
Input: nums = [1, 2, 4, 5], value = 4
Output: 2
Explanation: nums[2] is 4
Note:
Your algorithm should run in O(log n) time and use O(1) extra space.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check