contains(Object o) in ArrayList has O(n) time complexity