Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
<code>"A man, a plan, a canal: Panama"</code> is a palindrome.
<code>"race a car"</code> is not a palindrome.
Note:
Have you consider that the string might be empty? This is a good question to ask during an interview.
For the purpose of this problem, we define empty string as valid palindrome.
驗證一個字元串是否是回文字元串。首先看看wiki上對于回文的解釋:回文,亦稱回環,是正讀反讀都能讀通的句子,亦有将文字排列成圓圈者,Famous examples include "Amore, Roma", "A man, a plan, a canal: Panama" and "No ‘x‘ in ‘Nixon‘"。
判讀一個字元串是否是回文,一種方法可以将字元串倒置然後和原字元串進行比較。這裡采用一種類似字元串翻轉的方法,通過從前後兩個方向來比較判斷是否是回文。本題中的有效字元是字母和數字,并且忽略字母大小寫。
如果你覺得本篇對你有收獲,請幫頂。
另外,我開通了微信公衆号--分享技術之美,我會不定期的分享一些我學習的東西.
你可以搜尋公衆号:swalge 或者掃描下方二維碼關注我

(轉載文章請注明出處: http://blog.csdn.net/swagle/article/details/28883129
)