Buttercola: Leetcode: Palindrome Permutation
Leetcode: Palindrome Permutation
Given a string, determine if a permutation of the string could form a palindrome.
For example,
Understand the problem:"code"
-> False, "aab"
-> True, "carerac"
-> True.The problem can be easily solved by count the frequency of each character using a hash map. The only thing need to take special care is consider the length of the string to be even or odd.
-- If the length is even. Each character should appear exactly times of 2, e.g. 2, 4, 6, etc..
-- If the length is odd. One and only one character could appear odd times.
Read full article from Buttercola: Leetcode: Palindrome Permutation
No comments:
Post a Comment