title: convert integer array into a binary tree
body: <p>I can already convert an array into a binary tree using following algorithm in java:</p>
  
  <pre><code>public class TreeNode {
      public TreeNode left, right;
      public int val;
  
      public TreeNode(int val) {
          this.val = val;
      }
  }
  
  public TreeNode arrayToTree(Integer[] input){
      TreeNode root = createTreeNode(input,1);
      return root;
  }
  
  private TreeNode createTreeNode(Integer[] input, int index){
      if(index&lt;=input.length){
          Integer value = input[index-1];
          if(value!=null){
              TreeNode t = new TreeNode(value);
              t.left = createTreeNode(input, index*2);
              t.right = createTreeNode(input, index*2+1);
              return t;
          }
      }
      return null;
  }
  </code></pre>
  
  <p>when the input is <em>{1,null,2,null,null,3}</em>, I get following tree:</p>
  
  <pre><code>1        
   \   
    2    
   /   
  3
  </code></pre>
  
  <p>however I think the input <em>{1,null,2,3}</em> is clear enough to define a tree like above. </p>
  
  <p>Any good idea to avoid the redundant <strong>nulls</strong> defined in the input array?</p>