All problems
Relation Pair Count
Problem
Given the number of entities found in each sentence, return the total number of unordered entity pairs across all sentences.
A sentence with n entities contributes n * (n - 1) / 2 pairs.
Hint
Count combinations of two entities with integer division.
Test cases
case 1
in: [[2,3]]
expected: 4
case 2
in: [[1,1]]
expected: 0
case 3
in: [[]]
expected: 0
case 4
in: [[4]]
expected: 6
Starter codePython
def relation_pair_count(counts):
# Your code here
pass4 test cases · run your code against them in the editor