简历:The Google Resume: How to Prepare for a Career and Land a Job at Apple, Microsoft, Google, or any Top Tech Company
算法学习书籍:Introduction to Algorithms
编程珠玑:Programming Pearls (2nd Edition)
C++ 学习:The C++ Programming Language, 4th Edition
经典操作系统书籍,龙书:Operating System Concepts
创业:The Start-up of You: Adapt to the Future, Invest in Yourself, and Transform Your Career
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama"
is a palindrome."race a car"
is not a palindrome.
Note:
Have you consider that the string might be empty? This is a good question to ask during an interview.
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.
» Solve this problemThis problem reminds me of quicksort. There is one quicksort algorithm is start searching in both ends. Pick a pivot, if list[i]<pivot, i++, if(list[j]>pivot) j--. Until we found a pair of elements that they should swap. In this problem, it's the same. We set two pointers, to filter those elements that are not numbers or characters. Then compare.
PS: I learned the code from 水中的鱼
No comments:
Post a Comment