private boolean sameBST1(List<Integer> arr1, List<Integer> arr2){
        if(arr1.size() == 0 && arr2.size() == 0){
            return true;
        }
        if(arr1.size() == 0 || arr2.size() == 0){
            return false;
        }
        
        if(arr1.get(0) != arr2.get(0)){
            return false;
        }
        List<Integer> smaller1 = new ArrayList<Integer>();
        List<Integer> larger1= new ArrayList<Integer>();
        boolean first = true;
        for(Integer i : arr1){
            if(first){
               first = false;
               continue;
            }
            if(i <= arr1.get(0)){
                smaller1.add(i);
            }else{
                larger1.add(i);
            }
        }
        first = true;
        List<Integer> smaller2 = new ArrayList<Integer>();
        List<Integer> larger2= new ArrayList<Integer>();
        for(Integer i : arr2){
            if(first){
               first = false;
               continue;
            }
            if(i <= arr2.get(0)){
                smaller2.add(i);
            }else{
                larger2.add(i);
            }
        }
        boolean r = compare(smaller1, smaller2) && compare(larger1, larger2);
        if(!r){
            return false;
        }
        return sameBST1(smaller1, smaller2) && sameBST1(larger1, larger2);
        
    }
It might not work for duplicate elements in array. For that you have to store
both index and actual value to differentiate somehow.
src/com/interview/tree/IdenticalTrees.java