Given a sorted array of integers `nums` and a target value `target`, return the index of `target` if it is in the array. If not, return `-1`.
You must write an algorithm with O(log n) runtime complexity.
def binary_search(nums: list[int], target: int) -> int:
Given a sorted array of integers `nums` and a target value `target`, return the index of `target` if it is in the array. If not, return `-1`.
You must write an algorithm with O(log n) runtime complexity.
def binary_search(nums: list[int], target: int) -> int: