11.9.2024刷华为
文章目录
- HJ31 单词倒排
- HJ32 密码提取
- 语法知识记录
傻逼OD题目又不全又要收费,看毛线,莫名奇妙
HW这叼机构别搁这儿害人得不得?
我觉得我刷完原来的题目
过一遍华为机考的ED卷出处,就行了
HJ31 单词倒排
游戏本做过了好像
HJ32 密码提取
https://www.nowcoder.com/practice/3cd4621963e8454594f00199f4536bb1?tpId=37&tags=&title=&difficulty=0&judgeStatus=0&rp=1&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37
import sys
str1 = input()
str1 = list(str1)
res = 0
for i in range(len(str1)):
if i == 0:
continue
left = str1[0:i]
right = str1[i:]
shortLen = min(len(left), len(right))
count = 0
for j in range(shortLen):
if left[-(j+1)] == right[j]:
count += 2
else:
break
res = max(res, count)
#单数对称的情况
for i in range(len(str1)-1):
if i == 0:
continue
left = str1[0:i]
right = str1[i+1:]
mid = str1[i]
shortLen = min(len(left), len(right))
count = 1
for j in range(shortLen):
if left[-(j+1)] == right[j]:
count += 2
else:
break
res = max(res, count)
print(res)