描述
给出一个源字符串sourceString和一个目标字符串数组targetStrings,判断目标字符串数组中的每一个字符串是否是源字符串的子串
样例
样例 1:
输入: sourceString = "abc" ,targetStrings = ["ab","cd"]
输出: [true, false]
样例 2:
输入: sourceString = "lintcode" ,targetStrings = ["lint","code","codes"]
输出: [true,true,false]
class Solution:
"""
@param sourceString: a string
@param targetStrings: a string array
@return: Returns a bool array indicating whether each string in targetStrings is a substring of the sourceString
"""
def whetherStringsAreSubstrings(self, sourceString, targetStrings):
# write your code here
result = []
for string in targetStrings:
if string in sourceString:
result.append(True)
else:
result.append(False)
return result
娱乐一行流:
class Solution:
"""
@param sourceString: a string
@param targetStrings: a string array
@return: Returns a bool array indicating whether each string in targetStrings is a substring of the sourceString
"""
def whetherStringsAreSubstrings(self, sourceString, targetStrings):
# write your code here
return[result in sourceString for result in targetStrings]