Leetcode: Valid palindrome

Source: Internet
Author: User

1. Handle empty strings;

2. Note that it is the alphanumeric character;

3. You can add a character to the string directly with +;

1 class solution: 2 # @ Param S, a string 3 # @ return a Boolean 4 def ispalindrome (self, S): 5 ret = False 6 S = S. lower () 7 SS = "" 8 For I in S: 9 if I. isalnum (): 10 SS + = i11 H = 012 E = Len (SS)-113 while (H <E ): 14 if (ss [H] = ss [e]): 15 h + = 116 e-= 117 else: 18 break19 if h> = E: 20 ret = true21 return ret

 

Leetcode: Valid palindrome

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.