Number of pairs with maximum sum
Submissions: 2404   Accuracy:

38.45%

  Difficulty: Easy   Marks: 2

Given an array arr[], count number of pairs arr[i], arr[j] such that arr[i] + arr[j] is maximum and i < j.

Example:
Input  : arr[] = {1, 1, 1, 2, 2, 2}
Output : 3
Explanation: The maximum possible pair
sum where i is less than j is  4, which is given 
by 3 pairs, so the answer is 3
the pairs are (2, 2), (2, 2) and (2, 2).


CONSTRAINTS:
1<=T<=100
1<=a[i],n<=105

INPUT:
2
6
1 1 1 2 2 2
6
1 4 3 3 5 1
OUTPUT:
3
1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre
Author: saksham0751


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.