奇安信2020秋招测试开发工程师笔试题
根据这位博主的题目写的练习
第一题:
class Solution(object):
"""docstring for Solution"""
def f(self, s):
max_len = 0
str_dict = {}
one_len = 0
if s is None or len(s) == 0:
return 0
flag = 0
for i in range(len(s)):
if s[i] in str_dict and str_dict[s[i]] >= flag:
flag = str_dict[s[i]] + 1
one_len = i - flag + 1
str_dict[s[i]] = i
max_len =max(max_len,one_len)
return max_len
if __name__ == '__main__':
sol = Solution()
print(sol.f("aaaaaaaaaaaa"))
print(sol.f("jakhfjkshfjkhasjkhfs"))
第二题
num = input("input:")
n = int(num)
list_people=[]
for i in range(0,n): #将所有的人进行入队
list_people.append(i)
list_chu=[]
index = 0
for i in range(0,n):
index = (index + 4)%len(list_people)
list_chu.append(list_people[index])
list_people.remove(list_people[index])
print(list_chu.index(n-1)+1)