title: Find the smallest non-negative integer not contained in a binary tree
body: <p>the method return the smallest non-negative integer number that is not contains in the binary tree.</p>
  
  <p>Example:</p>
  
  <p>with 0 1 2 3 return 4.</p>
  
  <p>with 1 2 3 4 return 0.</p>
  
  <p>with 0 1 2 5 6 return 3.</p>
  
  <p>with 6 1 5 2 return 3.</p>
  
  <p>Complexity of my solution is O(n^2). How I can resolve in a time no more than O(n)?</p>
  
  <pre><code>public static &lt;E&gt; int minIntNotContains(BinTree&lt;Nodo&lt;Integer&gt;&gt; node) {
      List&lt;Integer&gt; a=new ArrayList&lt;Integer&gt;();
      int min=minIntNotContainsRic(node,a);
      return min;
  }
  
  public static &lt;E&gt; int minIntNotContainsRic(BinTree&lt;Nodo&lt;Integer&gt;&gt; node,List&lt;Integer&gt; a) {
      int min= node.getValue().getValue();
      a.add(node.getValue().getValue());
      if(node.getLeftSubtree() != null) {
          min = Math.min(min, minIntNotContainsRic(node.getLeftSubtree(),a));
      }
      if(node.getRightSubtree() != null) {
          min = Math.min(min, minIntNotContainsRic(node.getRightSubtree(),a));
      }
      if (min&gt;0) return 0;  
      else{
          for (int i=0;i&lt;a.size();i++){
              if (!a.contains(i+1)){
                  return i+1;
              }
          }
          return min;
      }           
  }
  </code></pre>