Given a string s, return the longest palindromic substring in s.
Example 1:
Input: s = "babad"
Output: "bab"
Note: "aba" is also a valid answer.
Example 2:
Input: s = "cbbd"
Output: "bb"
Example 3:
Input: s = "a"
Output: "a"
Example 4:
Input: s = "ac"
Output: "a"
Constraints:
public class Solution
{
public string LongestPalindrome(string s){
if(String.IsNullOrEmpty(s)){
return s;
}
string longest=s.Substring(0,1);
for(int i=0;i<s.Length;++i){
string temp = used(s,i,i);
if(temp.Length>longest.Length){
longest = temp;
}
temp=used(s,i,i+1);
if(temp.Length>longest.Length){
longest = temp;
}
}
return longest;
}
public string used(string s, int star, int end){
while(star>=0&&end<s.Length&&s[star]==s[end]){
--star;
++end;
}
return s.Substring(star+1,end-star-1);
}
}
>>: iOS APP 开发 OC 第十五天,网路请求(请求方式对比,缓存策略,请求时长)
也许你早就听过 WebAssembly 这个词,传说中它可以让 C, C++, Rust 等系统语...
DAY17 介绍 Azure Machine Learning SDK 我们前面一半的课程,学习了透...
前言 该系列是为了让看过Vue官方文件或学过Vue但是却不知道怎麽下手去重构现在有的网站而去规画的系...
1 前言 近年来深度学习使用在许多比赛中,但几乎都使用ensemble(集成)的方式或是使用庞大的模...
制作表单 createRadio(); 沿用上一个文章的参考 加上以下设定 我们可以用radio去做...