dp
of length len(s) + 1
with all elements set to 0.s
, updating the dp
array at each index i + 1
with the XOR of dp[i]
and 1 << (ord(s[i]) - ord('a'))
.[left, right, k]
, calculate the XOR of dp[right + 1]
and dp[left]
to get the parity difference.k
, the substring can be rearranged into a palindrome, so add True
to the result list. Otherwise, add False
.