网易互娱笔试0ac代码
# 插入子串成为回文串 91.3%
class Solution:
def canBePalindromicString(self, str1):
n = len(str1)
left = 0
right = n - 1
while left < right:
if str1[left] == str1[right]:
n -= 2
left += 1
right -= 1
if n <= 5:
return 1
else:
return 0
# 最长连续1的长度 90%
C, K = map(int, input().split())
c = str(C)
n = len(c)
ANS = []
for i in range(K, n):
K1 = K
ans = 0
for j in range(i, -1, -1):
if c[j] == '1':
ans += 1
else:
K1 -= 1
if K1 >= 0:
ans += 1
if K1 < 0:
break
ANS.append(ans)
print(max(ANS))
# 航班选座系统 10%
N, C = map(int, input().split())
zuowei = []
for i in range(N):
zuowei.append(list(map(str, input().split())))
mat = [[0]*7 for _ in range(N)]
ans = 0
# for i in range(N):
# for j in range(9):
# if zuowei[i][0][j] == '.' and j < 3:
# mat[i][j] = 1
# ans += 1
# if zuowei[i][0][j] == '.' and j > 5:
# mat[i][j-2] = 1
# ans += 1
# if ans > C:
# print('SUCCESS')
# for i in range(N):
# for j in range(9):
# if zuowei[i][0][j] == '.' and j == 0:
# print(str(j+1)+'A')
# C -= 1
# if zuowei[i][0][j] == '.' and j == 1:
# print(str(j+1)+'B')
# C -= 1
# if zuowei[i][0][j] == '.' and j == 2:
# print(str(j+1)+'C')
# C -= 1
# if zuowei[i][0][j] == '.' and j == 6:
# print(str(j-2)+'D')
# C -= 1
# if zuowei[i][0][j] == '.' and j == 7:
# print(str(j-2)+'E')
# C -= 1
# if zuowei[i][0][j] == '.' and j == 8:
# print(str(j-2)+'F')
# C -= 1
# if C == 0:
# break
# if C == 0:
# break
# else:
print('FAILED')
# 升序数组第k小 66.67%
class Solution:
def find_kth(self, arr1, arr2, k):
arr = arr1 + arr2
arr.sort()
return arr[k-1] #网易互娱##笔经#
查看17道真题和解析