easy Searching
Binary Search
Given a sorted (ascending) array `nums` and a `target`, return the index of `target`, or -1 if it is not present. Aim for O(log n). Example: nums = [1, 3, 5, 7, 9], target = 7 → 3.
runs in your browser
Given a sorted (ascending) array `nums` and a `target`, return the index of `target`, or -1 if it is not present. Aim for O(log n). Example: nums = [1, 3, 5, 7, 9], target = 7 → 3.