All problems
BPE Pair Frequency Count
Problem
Count adjacent symbol pairs across a list of words, where each word is a list of symbols.
Return [left, right, count] for the most frequent pair, breaking ties by lexicographic order. Return an empty list when there is no adjacent pair.
Hint
Tally pair tuples, then scan the sorted keys and keep the first strict maximum.
Test cases
case 1
in: [[["a","b","a","b"]]]
expected: ["a","b",2]
case 2
in: [[["l","o","w"],["l","o","w","e","r"]]]
expected: ["l","o",2]
case 3
in: [[["a"]]]
expected: []
case 4
in: [[]]
expected: []
case 5
in: [[["x","y"],["y","x"]]]
expected: ["x","y",1]
Starter codePython
def bpe_pair_frequency(words):
# Your code here
pass5 test cases · run your code against them in the editor