728x90
https://leetcode.com/problems/count-the-number-of-consistent-strings
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
count = 0
for string in words:
consistent = True
for n in string:
if n not in allowed:
consistent = False
break
if consistent is True:
count += 1
return count
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 2956. Find Common Elements Between Two Arrays (0) | 2024.02.23 |
---|---|
[Leetcode] 804. Unique Morse Code Words (0) | 2024.02.23 |
[Leetcode] 1832. Check if the Sentence Is Pangram (0) | 2024.02.22 |
[Leetcode] 2006. Count Number of Pairs With Absolute Difference K (0) | 2024.02.22 |
[Leetcode] 2367. Number of Arithmetic Triplets (0) | 2024.02.22 |