Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - Count Common Words With One Occurrence - Python
Views: 2 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# @leet start
class Solution:
    def countWords(self, words1: list[str], words2: list[str]) -> int:
        count = 0
        words = set(words1)
        for word in words:
            if words1.count(word) == 1 == words2.count(word):
                count += 1
        return count
# @leet end