Find the target
EasyYou're handed a finished binary search. It even finds
5 in the example. Run it anyway.Given a sorted array of integers and a target, write a function that returns the index of the target, or
-1 if it is not there.For example, given
nums = [1, 3, 5, 7, 9]target = 5
Your function should return
2.The starter uses
while lo < hi. Run it first.Try it first
Solution
10 Essential DSA in the AI era Coding Interview Problems
Master DSA in the AI era by trying the coding challenges below.
- 1.Count occurrencesEasy
- 2.Fix the default listEasy
- 3.Move zeroesEasy
- 4.Is subsequenceEasy
- 5.First unique characterEasy
- 6.Group anagramsMedium
- 7.Climb stairsEasy
- 8.Find the targetEasy
- 9.Drop zero countsEasy
- 10.Same valueEasy
