Home

Sorted Search

Given an array of integers nums which is sorted in ascending order and an integer target, write a function to search for target in nums. If target exists in nums, then return its index. Otherwise, return -1.

😱 WARNING: JavaScript does not support integer division by default! Use Math.floor() instead.

Bonus: Can you solve this in O(log n) time?

sortedSearch([6, 9], 6) → 0
sortedSearch([-5, 0, 9], 420) → -1
sortedSearch([], 5) → -1

😳 TIME LEFT: seconds 😳

function sortedSearch(nums, target) {

}

TOTAL TIME: seconds