public int numberOfTriangles(int input[]){
        Arrays.sort(input);
        
        int count = 0;
        for(int i=0; i < input.length-2; i++){
            int k = i+2;
            for(int j=i+1; j < input.length; j++){
                while(k < input.length && input[i] + input[j] > input[k]){
                    k++;
                }
                count += k - j -1;
            }
        }
        return count;
        
    }
http://www.geeksforgeeks.org/find-number-of-triangles-possible/
src/com/interview/array/NumberOfTrianglesInUnsortedArray.java