最大公共字符串leetcode-longest-palindromic-substring:查找字符串中最长的回文子串

时间:2021-07-01 01:23:11
【文件属性】:
文件名称:最大公共字符串leetcode-longest-palindromic-substring:查找字符串中最长的回文子串
文件大小:988B
文件格式:ZIP
更新时间:2021-07-01 01:23:11
系统开源 最大公共字符串leetcode 最长回文子串 给定一个字符串 s,找出 s 中最长的回文子串。 您可以假设 s 的最大长度为 1000。 Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" 实现:O(n^2) class Solution { int resultStart; int resultLength; public String longestPalindrome ( String s ) { int strLength = s . length(); if (strLength < 2 ) { return s; } for ( int start = 0 ; start < strLength - 1 ; start ++ ) { expandRange(s, start, start); expandRange(s, start, start + 1 ); } return s . substri
【文件预览】:
longest-palindromic-substring-master
----README.md(1KB)

网友评论