I have an array (or possibly a set) of integers (potentially non sequential but all unique) and a range of (sequential) numbers. If I wanted to check if any of the numbers in the range existed in the array, what would be the most efficient way of doing this?
array = [1, 2, 5, 6, 7]
range = 3..5
I could iterate over the range and check if the array include? each element but this seems wasteful and both the array and the range could easily be quite large.
Are there any methods I could use to do some sort of array.include_any?(range), or should I look for efficient search algorithms?