当前位置:网站首页>Force buckle 1961 Check whether the string is an array prefix

Force buckle 1961 Check whether the string is an array prefix

2022-07-07 20:06:00 Tomorrowave

1961. Check whether the string is an array prefix

Give you a string s And an array of strings words , Please judge s Is it words Of Prefix string .

character string s To be words Of Prefix string , Need to meet :s Can be words In front of k(k by Positive numbers ) Strings are concatenated in order to get , And k No more than words.length .

If s yes words Of Prefix string , return true ; otherwise , return false .

Code section

class Solution:
    def isPrefixString(self, s: str, words: List[str]) -> bool:
        b=''
        for i in range(len(words)):
            b+=words[i]
            if b==s:
                return True
        return False
原网站

版权声明
本文为[Tomorrowave]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071753356077.html