title: What is the best way to find common elements from 2 sets?
body: <p>Recently I had an interview and I was asked one question.</p>
  
  <p>I have 2 sets with around 1 Million records each. 
  I have to find the common element in 2 sets.</p>
  
  <p>My response:</p>
  
  <p>I will create a new empty Set.  And i gave him below solution but he was not happy with it. He said there are 1 million records so the solution won't be good.</p>
  
  <pre><code>public Set&lt;Integer&gt; commonElements(Set&lt;Integer&gt; s1, Set&lt;Integer&gt; s2) {
      Set&lt;Integer&gt; res = new HashSet&lt;&gt;();
       for (Integer temp : s1) {
          if(s2.contains(temp)) {
              res.add(temp);
          }
       }
       return res;
  }
  </code></pre>
  
  <p>What is the better way to solve this problem then?</p>