title: Find the pair in array with condition
body: <p>Let say I have an array of Int, I want to find a pair of number in this array that the sum of this pair is equal to an number, like so:</p>
  
  <pre><code>func findPair(list: [Int], _ sum: Int) -&gt; (Int, Int)? {
      for i in 0..&lt;list.count - 1{
          for j in (i+1)..&lt;list.count {
              let sumOfPair = list[i] + list[j]
              if sumOfPair == sum {
                  return (list[i], list[j])
              }
          }
      }
      return nil
  }
  </code></pre>
  
  <p>The first parameter is an array of Int, the second parameter is an number that we need to compare some pairs in that array.</p>
  
  <p>For example:</p>
  
  <pre><code>findPair([1,2,3,4,5], 7) // will return (2, 5), because 2 + 5 = 7
  </code></pre>
  
  <p>But the complexity of this algorithm is <strong>O(n^2)</strong>.</p>
  
  <p>Is there any way faster?</p>