题目传送门
很简单,遍历一次字符串,将‘?’作为0或1处理,发现00和11统计次数即可。
python">s = str(input())
cnt = 0
arr = ['00', '11', '0?', '?0', '1?', '?1', '??']
i=0
while i < len(s)-1:if s[i:(i+2)] in arr:i += 2cnt += 1else:i += 1
print(cnt)
END✨
题目传送门
很简单,遍历一次字符串,将‘?’作为0或1处理,发现00和11统计次数即可。
python">s = str(input())
cnt = 0
arr = ['00', '11', '0?', '?0', '1?', '?1', '??']
i=0
while i < len(s)-1:if s[i:(i+2)] in arr:i += 2cnt += 1else:i += 1
print(cnt)
END✨