Shared Once

Sometimes you need to find words that appear in two lists but never repeat in either one. Write a function count_words that receives two word lists, words1 and words2. Count how many words appear exactly once in the first list and exactly once in the second list. Return that count.

Примеры

Ввод
["leetcode", "is", "amazing", "as", "is"], ["amazing", "leetcode", "is"]
Вывод
2
Ввод
["b", "bb", "bbb"], ["a", "aa", "aaa"]
Вывод
0
Ввод
["a", "ab"], ["a", "a", "a", "ab"]
Вывод
1

Нужно реализовать

def count_words(words1: list[str], words2: list[str]) -> int:

Теги

stringshashmapdict
PostgreSQLv16

Tu sa zobrazí výsledok spustenia kódu

Visible tests
1
Input
["leetcode","is","amazing","as","is"], ["amazing","leetcode","is"]
Expected2
2
Input
["b","bb","bbb"], ["a","aa","aaa"]
Expected0
3
Input
["a","ab"], ["a","a","a","ab"]
Expected1
4
Input
["x"], ["x"]
Expected1
5
Input
["x","x"], ["x"]
Expected0
6
Input
["p","q","r"], ["q","r","s"]
Expected2
Focus radio
Paused · SomaFM · Fluid