3. Longest Substring Without Repeating Characters
给定一个字符串,找到最长子串的长度,而不重复字符。
https://www.cnblogs.com/K-artorias/p/7665604.html
5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad" Output: "bab" Note: "aba" is also a valid answer.
Example 2:
Input: "cbbd" Output: "bb"
int expandAroundCenter(char *s, int left, int right){ int len=0; char *p; p=s; while(*p){ p++; len++; } int L=left; int R=right; while(L>=0 && R< len && *(s+L)==*(s+R)){ L--; R++; } return R-L-1; } char* longestPalindrome(char* s) { char *p; p=s; int len=0; while(*p){ len++; p++; } int start=0; int end=0; for (int i=0; i<len; i++){ int len1=expandAroundCenter(s, i, i); int len2=expandAroundCenter(s, i, i+1); int len=len1>len2?len1:len2; if(len>end-start){ start=i-(len-1)/2; end=i+len/2; } } char *resP; char res[2000] = {0}; resP=res; p=s; int j=0; for(int i=start;i<=end;i++){ res[j]=*(p+i); j++; } res[j]='