How to find closest smaller number in array with C++?

Consider this array: std::vector<int> numbers = { 0, 4, 12, 60, 89 }; It is sorted and only has positive numbers. What is the easiest way to find closest smaller number in the array, preferably from <algorithm>? Example: Number Result 0 0 3 0 15 12 74 60 150 89 >Solution : What is the… Read More How to find closest smaller number in array with C++?