You are viewing a single comment's thread. Return to all comments →
You don't need binary search. Build a Set with all the numbers, then
Set<Integer> numbers = ... long matchCount = numbers.stream() .filter(i -> numbers.contains(i - k)) .count();
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
You don't need binary search. Build a Set with all the numbers, then