Count of subarrays of size K having at least one pair with absolute difference divisible by K | C ++ implementation of the above approach ; Function to return the required number of subarrays ; Return number of possible subarrays of length K ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findSubarrays ( int arr [ ] , int N , int K ) { return N - K + 1 ; } int main ( ) { int arr [ ] = { 1 , 5 , 3 , 2 , 17 , 18 } ; int K = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findSubarrays ( arr , N , K ) ; return 0 ; }