관리 메뉴

솜씨좋은장씨

[leetCode] 1961. Check If String Is a Prefix of Array (Python) 본문

Programming/코딩 1일 1문제

[leetCode] 1961. Check If String Is a Prefix of Array (Python)

솜씨좋은장씨 2022. 1. 31. 00:33
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 leetCode의 Check If String Is a Prefix of Array 입니다.

 

Check If String Is a Prefix of Array - LeetCode

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

 

👨🏻‍💻 코드 ( Solution )

class Solution:
    def isPrefixString(self, s: str, words: List[str]) -> bool:
        answer = False
        
        check_string = ""
        
        for word in words:
            check_string += word
            
            if len(check_string) > len(s):
                break
                
            if check_string == s:
                answer = True
                break
            
        return answer

 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments