Find the largest value smaller than x in a sorted array

Viewed 15742

Suppose I have a sorted array of integers int[], and I want to search the closest smaller value to some input number.

for example if the array contains (1) , (23), (57) , (59), (120) and the input is 109, the output should be 59.

I am just trying to see suggestions and compare to the approaches I already have.

5 Answers
Related