Arrays, as foundational data structures in programming, exhibit two key characteristics: zero-based indexing and contiguous memory allocation. This guide explores essential algorithms for manipulating arrays, demonstrating efficient solutions to common problems.
Question: Array Search
Imagine an array nums of integers sorted in ascending order and a target integer. The task is to develop a function to search for target in nums. If target is found, return its index; otherwise, return -1.