1177. 构建回文串检测 - 力扣(LeetCode)
1542. 找出最长的超赞子字符串 - 力扣(LeetCode)
- 前缀和
-
x^x=0
, 可以根据此性质判断 str[i] 出现的奇偶性 - 遍历到
str[i]
时:
3.1mask
最早出现的位置为j
, 那么说明str[j...i]
之间的数字真好都出现了偶数次,那么肯定是一个回文串,更新答案为i- pos[mask]
3.2 枚举d
,0<=d<10
, 如果对应的mask^d
之前出现过,那么更新答案为i - pos[mask^d]