For example: we have a list:
1 2 3 7 8 9 11 12
We need to check if a range (A,B) overlaps with the list, e.g range (4, 6) does NOT overlap with the list , range ( 10, 12) and range(5,9) do overlap with the list. I know we can put the list in a hashSet, then we just check if any element in range appears in that set. This costs O(N). N is the length of the range. Is there a better algorithm to solve this problem? I know there's an interval tree data structure, but I don't quite understand it. Can that structure solve this problem in logN?