NewThe Learning module is now liveSee what's new

Given a sorted array of integers (which may include duplicates) and a target value, implement a function to perform a binary search. If the target is present, return the index of its first occurrence. If the target is absent, return the index of the closest element that does not exceed the target.

Test Cases
Input
Output
Expected