class Solution(object): def generatePalindromes(self, s): d = collections.Counter(s) m = tuple(k for k, v in d.iteritems() if v % 2) p = ''.join(k*(v/2) for k, v in d.iteritems()) return [''.join(i + m + i[::-1]) for i in set(itertools.permutations(p))] if len(m) < 2 else 
Nice one. Though we should really have a test case like
s = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ... (you'd get TLE, even though there is just a single possibility).
Agree with stefan, and not sure if these advanced methods are ok for job interviews...
@StefanPochmann Thanks, just added your test case.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.