做爰网站爱情岛,批量更新wordpress文章,建程网是正规网吗,跨境电商平台数据题目#xff1a;
考察内容#xff1a; 思路转化#xff1a;求出o字母出现偶次#xff08;o的索引#xff09;#xff1b;环形–双倍字母#xff1b; 方法1#xff1a;循环变量双倍字母#xff08;保证环线#xff09;#xff0c;记录最大偶次#xff0c;如果是
考察内容 思路转化求出o字母出现偶次o的索引环形–双倍字母 方法1循环变量双倍字母保证环线记录最大偶次如果是则记录left和并替换left位置并添加子字符串 方法2直接求出双倍字母的索引根据最大偶次循环遍历索引求出子字符串。 代码 analyze:
环形如何实现
偶次0也包括
aloloboalolobo-- alolob;loboal;boalol; alolobinput:
小写字母字符串output:
int, o字母出现偶数次
eg:
alolobo
6looxdolx
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
# # right 1
# else:
# if double_s[left:i] not in temp_list:
# temp_list.append(double_s[left:i])
# left double_s.find(o, o_index) 1
# o_index left
# # right 1
# o_res 2
# elif o_res o_num:
# pass
# # right 1
# max_str 0
# for temp in temp_list:
# max_str max(0, len(temp))
# print(temp_list, max_str)# 优化
# 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
# 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:
# if double_s[left:i] not in temp_list:
# temp_list.append(double_s[left:i])
# # 获取o的索引
# left double_s.find(o, o_index) 1
# o_index left
# o_res 2
# max_str 0
# for temp in temp_list:
# max_str max(0, len(temp))
# print(temp_list, max_str)# 方法根据o的索引获取s_temp input()if o not in s_temp:print(len(s_temp))
else:o_res 0temp_index_list list()o_num s_temp.count(o)o_index 0double_s s_temp * 2print(double_s)for i in range(o_num*2):index double_s.find(o, o_index)o_index index 1temp_index_list.append(index)print(temp_index_list)# 取最大偶数if o_num % 2 ! 0:o_num o_num - 1res list()left, right 0, 0for i in range(len(temp_index_list)):if io_num len(temp_index_list):res.append(double_s[left:temp_index_list[io_num]])# print(double_s[left:temp_index_list[i2]])left temp_index_list[i]1print(res)