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
.
sortedSearch([6, 9], 6) → 0
sortedSearch([-5, 0, 9], 420) → -1
sortedSearch([], 5) → -1
😳 TIME LEFT: seconds 😳
function sortedSearch(nums, target) {
}
⏰ TOTAL TIME: seconds ⏰