Simple solution with Java 8 Stream API


  • 0
    X
    public boolean canPermutePalindrome(String s) {
        return s.chars().collect(HashMap::new, (m, i) -> m.compute(i, (k, v) -> v == null ? 1 : null), Map::putAll).size() <= 1;
    }
    

Log in to reply
 

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