title: Avoiding duplications when comparing array elements
body: <p>The question is something like: Go through an array and find pairs of elements that add up to a certain sum k. </p>
  
  <pre><code>for (auto i : array) {
     for (auto j : array) {
          if (i+j==k) {
              *Do something
          }
      }
  }
  </code></pre>
  
  <p>Say we had <code>array = [1,2,5]</code> and <code>k=3; when i=1 and j=2</code>, we would execute the <em>Do something</em>. But when <code>i=2</code> and <code>j=1</code>, we would execute <em>Do something</em> again, even though we have already found 2 elements and we would be repeating the answer.</p>
  
  <p>Essentially, how can one go through an array and avoid comparing the same 2 elements multiple times?</p>