Binary Search Implementation
viaGlassdoor
Problem: Implement binary search on a sorted array to find the index of a target value. Constraints: Array is sorted ascending; O(log n) time expected. Example: Input [1,3,5,7,9,11], target=7 -> Output index 3. Approach: Maintain low/high pointers, repeatedly compare target to mid element, narrowing the search range by half each iteration until found or range is empty.
asked …