Clean O(N) Java Solution


  • 0
    A
    public boolean canPermutePalindrome(String s) {
    	Set<Character> set = new HashSet<Character>();
    	for (char ch : s.toCharArray()) 
    		if (set.contains(ch)) set.remove(ch);
    		else set.add(ch);
    	return set.size() <= 1;
    }

Log in to reply
 

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