Given an array of integers `nums` which is sorted in ascending order, and an integer `target`, write a function to search `target` in `nums`. If `target` exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity.
Decrease and Conquer (Binary Search)
Since the array is sorted, we can compare the target with the middle element. If the target is smaller, it must be in the left half. If it's larger, it must be in the right half. This halves the search space at each step, leading to logarithmic time complexity.