본문 바로가기
python-algorithm

leetcode 2085. Count Common Words With One Occurrence

by 무적김두칠 2022. 3. 22.

1
2
3
4
5
6
class Solution:
    def countWords(self, words1: List[str], words2: List[str]) -> int:
        ans=0
        for i in words1:
            if i in words2 and words1.count(i)==1  and words2.count(i)==1:ans+=1
        return ans 
cs
반응형

댓글