题目:
考察内容:
思路转化:求出o字母出现偶次(o的索引);环形–双倍字母;
方法1:循环变量双倍字母(保证环线),记录最大偶次,如果是,则记录left和并替换left位置,并添加子字符串;
方法2:直接求出双倍字母的索引,根据最大偶次,循环遍历索引求出子字符串。
代码:
"""
analyze:
环形如何实现:
偶次(0也包括)
aloloboalolobo-- alolob;loboal;boalol; alolob
input:
小写字母字符串
output:
int, o字母出现偶数次
eg:
alolobo
6
looxdolx
7
way:
把所有还有两个0的子字符串求出来
根据o的索引获取(先求出最大偶数)
"""
# s_temp = input()
#
# if "o" not in s_temp:
# print(len(s_temp))
# else:
# o_res = 0
# temp_list = list()
# o_num = s_temp.count("o")
# # 取最大偶数
# if o_num % 2 != 0:
# o_num = o_num - 1
# # print(o_num)
# double_s = s_temp*2
# left, right = 0, 0
# o_index = 0
# for i in range(len(double_s)):
# if double_s[i] == "o":
# o_res += 1
# if o_res <= o_num:
# pass