今日头条笔试双生词
自己本地测没有问题啊?为什么提交就GG?很尴尬,头条笔试这是要招什么样的人了?import sys
def rotateString(str, offset):
if offset == 0 or not str:
return str
offset %= len(str)
str = list(str)
str = reverse(str, 0, len(str))
str = reverse(str, 0, offset)
str = reverse(str, offset, len(str))
return ''.join(str)
def reverse(str, start, end):
while (start < end):
tmp = str[start]
str[start] = str[end - 1]
str[end - 1] = tmp
start += 1
end -= 1
return str
if __name__ == "__main__":
t = int(sys.stdin.readline().strip())
l = []
for i in range(t):
n = int(sys.stdin.readline().strip())
tmp = []
for j in range(n):
s1 = sys.stdin.readline().strip()
tmp.append(s1)
l.append(tmp)
for i in l:
if len(i[0])!=len(i[1]):
print('Sad')
continue
else:
flag = True
for j in range(len(i[0])):
kk = rotateString(i[0],j)
if kk==i[1] or ''.join(list(reversed(kk)))==i[1]:
print('Yeah')
flag = False
break
if flag:
print('Sad')
#字节跳动#