All problems
Hapax Count
Problem
Return the number of distinct tokens that occur exactly once in the token list.
Count types, not occurrences, so a token repeated twice contributes nothing.
Hint
Build a frequency table, then count entries equal to 1.
Test cases
case 1
in: [["a","b","c","a"]]
expected: 2
case 2
in: [["a","a","a"]]
expected: 0
case 3
in: [[]]
expected: 0
case 4
in: [["x","y","z"]]
expected: 3
Starter codePython
def hapax_count(tokens):
# Your code here
pass4 test cases · run your code against them in the editor