본문 바로가기

IT/코딩테스트

[Leetcode] 1684. Count the Number of Consistent Strings

728x90

https://leetcode.com/problems/count-the-number-of-consistent-strings

 

Count the Number of Consistent Strings - LeetCode

Can you solve this real interview question? Count the Number of Consistent Strings - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

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