Count triplet in java

Task - 
You will be given an array and a number and you need to find the number of triplet in the array whose sum is equal to given number in the input. 


Input Format - 
you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them. Next line should have a integer value. 

Output Format 
you need to print the number of triplet of integers in the array whose sum is equal to the given integer. 


Sample Test Case: 
Sample Input:-4
2 5 7 -1

Sample Output 
1

Explanation: 
There is 1 triplet with sum 6 which is (2, 5, -1). So, output is 1.

Comments

Popular posts from this blog

Reasoning-Number Series

Reasoning-Letter Series

Profit and Loss