title: Ruby - Find element not in common for two arrays
body: <p>I've been thinking about a following problem - there are two arrays, and I need to find elements not common for them both, for example:</p>
  
  <pre><code>a = [1,2,3,4]
  b = [1,2,4]
  </code></pre>
  
  <p>And the expected answer is <code>[3]</code>.</p>
  
  <p>So far I've been doing it like this:</p>
  
  <pre><code>a.select { |elem| !b.include?(elem) }
  </code></pre>
  
  <p>But it gives me <code>O(N ** 2)</code> time complexity. I'm sure it can be done faster ;)</p>
  
  <p>Also, I've been thinking about getting it somehow like this (using some method opposite to <code>&amp;</code> which gives common elements of 2 arrays):</p>
  
  <pre><code>a !&amp; b  #=&gt; doesn't work of course
  </code></pre>
  
  <p>Another way might be to add two arrays and find the unique element with some method similar to <code>uniq</code>, so that:</p>
  
  <pre><code>[1,1,2,2,3,4,4].some_method #=&gt; would return 3
  </code></pre>