Delete 复试笔记/21笔试代码 directory

真题修改
This commit is contained in:
Sheldoer
2021-04-06 10:51:44 +08:00
committed by GitHub
parent 5684cf6915
commit 4666e4b2b0
4 changed files with 0 additions and 66 deletions

View File

@@ -1,17 +0,0 @@
def find_next(L):
length=len(L)
res=[]
for i in range(length):
flag=0 #flag
for j in range(i+1,length):
if L[j]>L[i]:
res.append(L[j])
flag=1
break
if flag==0:
res.append(None)
return res
if __name__=='__main__':
L=[2,3,5]
L=[5,2,3]
print(find_next(L))

View File

@@ -1,20 +0,0 @@
def find_pair(L):
length=len(L)
mxmul=L[0]*L[1]
indext=(L[0],L[1])
for i in range(length):
for j in range(i+1,length):
if L[i]*L[j]>=mxmul:
mxmul=L[i]*L[j]
indext=(L[i],L[j])
indext=list(indext)
indext.sort()
return (indext[0],indext[1])
if __name__=='__main__':
#L=[1,-1,0]
L=[-10,-3,5,6,-2]
print(find_pair(L))

View File

@@ -1,10 +0,0 @@
def find_number(n):
res=[]
for i in range(n+1):
s=bin(i)[2:] #remove '0b'
if s.count('1')>s.count('0'):
res.append(i)
return res
if __name__=='__main__':
print(find_number(15))

View File

@@ -1,19 +0,0 @@
def find_major(L):
length=len(L)
lst=[]
res=set()
for i in L:
for j in list(i):
lst.append(j)
for i in set(lst):
if lst.count(i)>length/2:
res.add(i)
if len(res)>0:
return res
if __name__=='__main__':
L=[{1},{1,2},{1}]
L=[{1},{2,3}]
print(find_major(L))