网易机器学习笔试code,橡皮长度
# -*- coding: utf-8 -*- import sys while 1: line = sys.stdin.readline().strip() if line: a = line else: break n = len(a) last = '' while last != a: last = a for i in range(n-1): left = a[0] right = a[-1] if a[i] == a[i+1] and left != right: a = a[:i+1][::-1] + a[i+1:][::-1] break count = 1 max = 1 for i in range(n-1): if a[i] != a[i+1]: count += 1 if count > max: max = count else: count = 1 print max
#笔试题目##网易#