顺丰笔试编程题,求解答
RT,那一道求查询单词在单词表中是多少个单词的前缀的编程题,虽然本地测试没问题,但是老是过不了,求解答。
代码如下:
t = input()
for i in range(int(t)):
f = 'Case #' + str(i + 1) + ': '
print(f)
m_n = input()
m = int(m_n.split()[0])
n = int(m_n.split()[1])
table = []
for j in range(m):
s = input()
table.append(s)
for j in range(n):
s = input()
count = 0
for k in table:
k = list(k)
if list(s) == k[:len(s)]:
count += 1
print(count)

