本地没问题,在线AC 为0 ,大佬帮忙看看~
题目描述: 两个字符串 input1和字符串input2,字符串中元素的值域是26个大写字母,判断input2中所有字符是否都包含在字符串input1中,包含返回 true,否则返回 false,
代码如下:(python 3)
def func(s1,s2):
length1 = len(s1)
length2 = len(s2)
if length1 <5 or length2 <5:
return False
if length1 < length2:
return False
list1 = [0]*26
list2 = [0]*26
index = 0
for i in range(length1):
asci_num = ord(s1[i])
if asci_num <65 or asci_num > 90:
return False
index = ord(s1[i])-65
list1[index] =1
for i in range(length2):
asci_num = ord(s2[i])
if asci_num <65 or asci_num > 90:
return False
index = ord(s2[i])-65
list2[index] =1
for i in range(26):
if list2[i] > list1[i]:
return False
return True
if __name__ == '__main__':
s1 = input('input first str:')
s2 = input('input second str:')
print (func(s1,s2))
#测试#length1 = len(s1)
length2 = len(s2)
if length1 <5 or length2 <5:
return False
if length1 < length2:
return False
list1 = [0]*26
list2 = [0]*26
index = 0
for i in range(length1):
asci_num = ord(s1[i])
if asci_num <65 or asci_num > 90:
return False
index = ord(s1[i])-65
list1[index] =1
for i in range(length2):
asci_num = ord(s2[i])
if asci_num <65 or asci_num > 90:
return False
index = ord(s2[i])-65
list2[index] =1
for i in range(26):
if list2[i] > list1[i]:
return False
return True
if __name__ == '__main__':
s1 = input('input first str:')
s2 = input('input second str:')
print (func(s1,s2))