hashmap containsKey complexity
问题 I have a method i wrote to find the duplicates in a List. It works fine but im concerned about the complexity of using containsKey. When we use containsKey we have to compute a hash function for every key and then compare against each with our search item, right ? So wouldn't the complexity be O(n) ? Here is the function: public void findDup(List<String> list){ HashMap<String,Integer> map = new HashMap<>(); int pos=0; for(String s: list){ if(map.containsKey(s)){ Log.v("myapp","duplicate found