Hacker rank doubt

I’m not getting the approach of the author mainly the last part in which he counts the number of Consecutive Subsequences.

Editorial : https://www.hackerrank.com/challenges/consecutive-subsequences/editorial

More specifically explain me this part,

 long long res = 0;
    for(int r = 0; r < k; r ++)
        res += (cnt[r]*(cnt[r]-1)/2);
    cout << res << endl;

it explains that we can choose any two numbers for a pair in nC2 or n*(n-1)/2 ways.

Reference https://stackoverflow.com/questions/16605991/number-of-subarrays-divisible-by-k

1 Like