public List<String> generatePalindromes(String s) {
        List<String> res = new ArrayList<String>();
        if (s == null) return res;

        int[] map = new int[256];
        for (int i = 0; i < s.length(); ++i) ++map[s.charAt(i)];
        List<Character> list = new ArrayList<Character>();
        String center = "";
        for (int i = 0; i < map.length; ++i) {
            if ((map[i] & 1) == 1) {
                if (!center.isEmpty()) return res;
                else center += (char) i;
            }
            for (int j = 0; j < map[i] / 2; ++j) list.add((char) i);
        }

        permute(res, "", list, center);

        return res;
    }