title: Big O: what is the time complexity for this algorithm?
body: <p>What is the best case and worst case time complexity for my method below?</p>
  
  <p>I know ArrayList.add() is of O(1) time complexity but not sure about <code>loaded.stream().distinct().collect(Collectors.toList());</code></p>
  
  <pre><code>  public static int countUnique(WordStream words) {
  
      ArrayList&lt;String&gt; loaded = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; empty = new ArrayList&lt;String&gt;();
  
      // Fill loaded with WordStream words
      for (String i : words) {
        loaded.add(i);
      }
  
      empty = (ArrayList&lt;String&gt;) loaded.stream().distinct().collect(Collectors.toList());
  
      return empty.size();
    }
  </code></pre>