We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def triplets(a, b, c):
a.sort()
c.sort()
count = 0
for b_val in b:
count_a = sum(1 for x in a if x <= b_val)
count_c = sum(1 for y in c if b_val>=y)
count += count_a * count_c
return count
Why is this partially correct?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Triple sum
You are viewing a single comment's thread. Return to all comments →
def triplets(a, b, c): a.sort() c.sort() count = 0 for b_val in b: count_a = sum(1 for x in a if x <= b_val) count_c = sum(1 for y in c if b_val>=y) count += count_a * count_c return count
Why is this partially correct?