title: Does initializing an array from a set have a complexity and if so what is it?
body: <p>Swift: Option 1</p>
  
  <pre><code>var dictionaryWithoutDuplicates = [Int: Int]()
  for item in arrayWithDuplicates {
     if dictionaryWithoutDuplicates[item] == nil {
        dictionaryWithoutDuplicates[item] = 1
     }
  }
  print(dictionaryWithoutDuplicates.keys)
  // [1,2,3,4]
  </code></pre>
  
  <p>Option 2</p>
  
  <pre><code>let arrayWithDuplicates = [1,2,3,3,2,4,1]
  let arrayWithoutDuplicates = Array(Set(arrayWithDuplicates))
  print(arrayWithoutDuplicates)
  // [1,2,3,4]
  </code></pre>
  
  <p>For the first option there might be a more elegant way to do it but that's not my point, I just wanted to show an example that has a complexity of n.
  Both options return an array without duplicates. Since the first option has a complexity of O(n), I was wondering if the second option even has a complexity and if so what is it?</p>