Test cases taking too much time

I have employed binary search, but despite that, the t est cases seem too take too much time. How to reduce time complexity further?

make your own upper bound and lower bound function, we are locating the leftmost (or rightmost) index containing target (rather than returning true iff we find target), the algorithm does not terminate as soon as we find a match. Instead, we continue to search until lo == hi and they contain some index at which target can be found