11.9.2024刷华为

54 阅读1分钟

傻逼OD题目又不全又要收费,看毛线,莫名奇妙 HW这叼机构别搁这儿害人得不得? 我觉得我刷完原来的题目 过一遍华为机考的ED卷出处,就行了

HJ31 单词倒排

游戏本做过了好像 在这里插入图片描述

HJ32 密码提取

www.nowcoder.com/practice/3c… 在这里插入图片描述

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)

语法知识记录