Count all distinct pairs with difference equal to k
#include
#include
using namespace std;
void printArray(int a[], int len)
{
for(int i=0;i k)
l++;
}
cout << "count =" << count;
}
int main() {
// your code goes here
int a[] = {8, 12, 16, 4, 0, 20};
cout << "array - ";
printArray(a, sizeof(a)/sizeof(a[0]));
countPairsWithDiffK(a, sizeof(a)/sizeof(a[0]), 4);
return 0;
}
No comments:
Post a Comment