private boolean findNumber(int src[],int dest[],int result[],int pos,boolean used[]){
        
        if(pos == result.length){
            return false;
        }
        
        boolean hasEqual = false;
        int nextGreaterIndex = -1;
        int equalIndex = -1;
        int nextGreaterDiff = Integer.MAX_VALUE;
        for(int i=0; i < src.length; i++){
            if(used[i]){
                continue;
            }
            if(dest[pos] == src[i]){
                hasEqual = true;
                equalIndex = i;
                continue;
            }
            if(src[i] > dest[pos]){
                if(src[i] - dest[pos] < nextGreaterDiff){
                    nextGreaterIndex = i;
                    nextGreaterDiff = src[i] - dest[pos];
                }
            }
        }
        //first try with equal item and see next numbers in array might find larger one.
        //if it fail try next larger number
        if(hasEqual){
            used[equalIndex] = true;
            result[pos] = src[equalIndex];
            if(findNumber(src,dest,result,pos+1,used)){
                return true;
            }
            used[equalIndex] = false;
        }
        if(nextGreaterIndex != -1){
            used[nextGreaterIndex] = true;
            result[pos] = src[nextGreaterIndex];
            sortRemaining(src, result, used, pos+1);
            return true;
        }
        return false;
    }
e.g if src array is {1,2,5,7,8} and dest is {5,8,1,9,8}
permute src in such a way that it is greater than dest but diff is minimal
so here we will have {5,8,2,1,7}
src/com/interview/number/PermutationLargerThanGivenArray.java