Reference: LeetCode
Difficulty: Easy

## Problem

Given a string, determine if a permutation of the string could form a palindrome.

Example:

## Analysis

### Brute-Force

List all possibilities and test if they satisfy palindromicity.

Note: Swapping characters in string can be done with StringBuilder.

Time: $O(N \times N!)$
Space: $O(N)$

### Hash Map

We can use hash map based on the fact that odd number of occurrences of a specific character can only occur once at most.

Actually, since there are only 128 ASCII characters, we can use an array of size 128 to store occurrences.

Note: But I think the code is not elegant.

A more elegant version:

Time: $O(N)$
Space: $O(N)$

### Hash Set

Idea: Only character with odd number of occurrences will be in the hash set.

Time: $O(N)$
Space: $O(N)$

Comment
Junhao Wang
Hi, I was a master student at USC studying Computer Science.