Question: Given an array of integers and a positive integer k determines the number of (i,j) pairs where i The solution in python is: I dont

Given an array of integers and a positive integer k determines the number of (i,j) pairs where i

The solution in python is:

Given an array of integers and a positive integer k determines the

I dont understand why for j in range(n, i+1, -1) why is there i+1 and -1?

and can you please explain the count +=1 ?

def divisiblesumPairs(n,k, ar): count = cor i in range (n): for j in range (n,i+1,1): if (ar [i]+ar[j1])%k==0: count +=1 returncount

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!