Pair Sum
9
1 3 6 2 5 4 3 2 4
7
7
public class Solution {
public static int pairSum(int arr[], int x) {
int l=arr.length;
int s=0;
int c=0;
for(int i=0;i<l;i++)
{
for(int j=i+1;j<l;j++)
{
s=arr[i]+arr[j];
if(s==x)
c++;
}
}
return c;
}
}
Comments
Post a Comment