5. Longest Palindromic Substring Leetcode Python 2016 new Season
来源:互联网 发布:网络文风 编辑:程序博客网 时间:2024/06/10 03:13
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
Show Similar Problems
There are two cases we need to deal with odd like 'ada' even like 'adda'
class Solution(object): def getPalindromeString(self, s, left_index, right_index): while left_index >= 0 and right_index < len(s) and s[left_index] == s[right_index]: left_index -= 1 right_index += 1 return s[left_index + 1 : right_index] def longestPalindrome(self, s): """ :type s: str :rtype: str """ longest_string = '' for index in range(len(s)): first_string = self.getPalindromeString(s, index, index) second_string = self.getPalindromeString(s, index, index + 1) if len(first_string) > len(longest_string): longest_string = first_string if len(second_string) > len(longest_string): longest_string = second_string return longest_string
0 0
- 5. Longest Palindromic Substring Leetcode Python 2016 new Season
- 3. Longest Substring Without Repeating Characters Leetcode Python New season for 2016
- 5.Longest Palindromic Substring Leetcode Python
- [Leetcode]5.Longest Palindromic Substring @ Python
- [leetcode: Python]5.Longest Palindromic Substring
- 【Leetcode】【python】Longest Palindromic Substring
- 14. Longest Common Prefix leetcode Python 2016 new Season
- 32. Longest Valid Parentheses leetcode python new season 2016
- LeetCode 5. Longest Palindromic Substring
- LeetCode --- 5. Longest Palindromic Substring
- LeetCode 5.Longest Palindromic Substring
- [Leetcode] 5. Longest Palindromic Substring
- [LeetCode]5.Longest Palindromic Substring
- [leetcode] 5. Longest Palindromic Substring
- LeetCode-5. Longest Palindromic Substring
- leetcode 5. Longest Palindromic Substring
- leetcode 5. Longest Palindromic Substring
- Leetcode 5. Longest Palindromic Substring
- JBoss AS7 快速配置
- oracle的正则表达式(regular expression)详细介绍
- 分层查询(Hierarchical Queries)
- windows下配置java程序bat启动
- oracle 外部表
- 5. Longest Palindromic Substring Leetcode Python 2016 new Season
- javascript对文本进行关键字过滤
- Oracle分析函数——函数RANK,DENSE_RANK,FIRST,LAST
- Android Fragment 真正的完全解析(上)
- oracle连接(join)中使用using关键字
- oracle 中 rollup、cube、grouping 使用详解
- oracle sequence-序列
- oracle flashback query(闪回查询)
- Android退出应用最优雅的方式(改进版)