topic:
Thought:
First useCountercount,use &
The symbol is connected to two dictionarieskeys, The remaining part is both。
Traversing this remaining part,Determine whether it is equal to 1 Be
Code:
1 | class Solution: |
1 | return sum(1 for i in Counter(words1) & Counter(words2) if Counter(words1)[i] == 1 and Counter(words2)[i] == 1) |