Using HashSet for Integers
<p>I have two lists. I want to find the smallest common number in the two. I thought of using HashSet as it doesn't allow duplicates. I can find out the common numbers while adding both list elements to it. And HashSet takes only <code>constant time</code> for insertion. This can give me <code>O(n)</code> to find the smallest common of two. But how can HashSet insert <code>n</code> elements in <code>constant time</code>? In this case to add the last element it takes <code>O(n)</code> time because to find the right bucket it has to compare hashcode with n buckets in the worst case. Please correct this and Thanks in advance..!</p>
