Skip to content

Instantly share code, notes, and snippets.

@gogamid
gogamid / gist:eb4cf3803bd7602a14a7cf8b11833da7
Last active October 21, 2022 20:56
is palindrome permutation with bit vector
public static boolean isPalindromePerm(String s) {
int checker = 0;
for (char c : s.toCharArray()) {
if ('a' <= c && c <= 'z') {
int val = c - 'a';
int mask = 1 << val;
if ((checker & mask) == 0) {
checker |= mask; //flip to 1
} else {
checker &= ~mask; //flip to 0