You are viewing a single comment's thread. Return to all comments →
My Python code that passed all test cases:
def solve(a): n1 = a.count(1) # no. of 1's in a n2 = a.count(2) # no. of 2's in a n = len(a) cnt_1_1 = n1*(n1 - 1)//2 # no. of (1,1) pairs cnt_2_2 = n2*(n2 - 1)//2 # no. of (2,2) pairs cnt_1_n = n1*(n - n1) # no. of (1,n) pairs return 2*cnt_1_1 + cnt_2_2 + cnt_1_n
Seems like cookies are disabled on this browser, please enable them to open this website
Pairwise Sum and Divide
You are viewing a single comment's thread. Return to all comments →
My Python code that passed all test cases: