A k-subsequence is defined as follows:

  • It is a subsequence of consecutive elements.
  • The sum of its elements, s, is evenly divisible by k (i.e.: s % k = 0).

Complete a function called kSub with two parameters: an integer, k, and an array of integers, nums, of size n.

Output Format :

Return the number of k-subsequences as an integer.

 

Sample Input:

3 
5 
1 2 3 4 1

Sample Output:

4

Explanation:

Below are the four consecutive subsequences with sums that are evenly divisible by k = 3:

3
1 2
1 2 3
2 3 4

Comments


A k-subsequence is defined as follows: It is a subsequence of consecutive elements. The sum of its elements, s,...

Read Post

A k-subsequence is defined as follows: It is a subsequence of consecutive elements. The sum of its elements, s,...

Read Post

Leave a Reply

Your email address will not be published. Required fields are marked *