LeetCode #Valid Palindrome#
来源:互联网 发布:基于tensorflow的应用 编辑:程序博客网 时间:2024/06/16 11:53
LeetCode #Valid Palindrome#
我的Python解答:
"""Programmer : EOFe-mail : jasonleaster@gmail.comDate : 2015.04.07File : vp.py"""import stringclass Solution: def isPalindrome(self, s): length = len(s) left = 0 right = length - 1 while left < right: if self.isCharacter(s[left]) is False: left += 1 continue if self.isCharacter(s[right]) is False: right -= 1 continue if string.lower(s[left]) != string.lower(s[right]): return False left += 1 right -= 1 return True def isCharacter(self, c): if c is None: return False if (c <= 'z' and c >= 'a') or \ (c <= 'Z' and c >= 'A') or \ (c <= '9' and c >= '0'): return True return False#---------------- just for testing --------------s = Solution()string_1 = "abcba"print string_1if s.isPalindrome(string_1) : print "is Palindrome"string_1 = "ab"print string_1if s.isPalindrome(string_1) : print "is Palindrome"string_1 = "1a2"print string_1if s.isPalindrome(string_1) : print "is Palindrome"
0 0
- [Leetcode] Valid Palindrome
- Leetcode: Valid Palindrome
- leetcode 55: Valid Palindrome
- [LeetCode] Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode - Valid Palindrome
- [leetcode]Valid Palindrome
- [LeetCode]Valid Palindrome
- [Leetcode]Valid Palindrome
- LeetCode-Valid Palindrome
- [leetcode] Valid Palindrome
- LeetCode 125: Valid Palindrome
- LeetCode - Valid Palindrome
- leetcode之Valid Palindrome
- LeetCode | Valid Palindrome
- [leetcode]Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode题解:Valid Palindrome
- apache 2.4配置mod_wsgi
- 程序员学习 集合
- [数学建模]马氏链模型(一)基本介绍
- move_uploaded_file 无返回值 一直失败
- 修改jetty服务器端口号
- LeetCode #Valid Palindrome#
- 实现ListView中item中Button和Item本身点击都有响应
- 陈正冲老师讲c语言之内存的申请malloc() 和释放free()
- windows,三个线程(+ ,- ,*);WaiForSingleObject;
- iOS设备分辨率、尺寸、图标大小等
- 时间管理总结
- Android动画开发——Animation动画效果详解
- 【新浪微博项目】06--自定义BadgeButton
- js中this的总结