Using BitSet


  • 0
    M

    public class Solution {
    public boolean canPermutePalindrome(String s) {
    if(s == null) {
    return true;
    }
    BitSet alphabetBit = new BitSet(Character.MAX_VALUE);
    for(int i =0; i<s.length(); i++) {
    char c = s.charAt(i);
    alphabetBit.flip(c);
    }
    return alphabetBit.cardinality() == (s.length() %2);
    }
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.