I\'m writing an algorithm where I look for pairs of values which when added together results in another value I\'m looking for.
I figured out that using a Map
Map
Map.containsKey() considering that you are using a HashMap since searching in HashMap is done in O(1).
List.contains() generally should resort to sequential search or a binary search thus the complexity will be atleast O(log n)