=0 && right<.">
赞
踩
- public static String longestPlalindrome(String originalStr){
-
- String resultStr= "";
-
- for(int i=0;i<originalStr.length();i++){
- int left=i-1;
- int right=i+1;
- while (left>=0 && right<=originalStr.length()-1 && originalStr.charAt(left) == originalStr.charAt(right)){
- left--;
- right++;
- }
- String str=right-left>2?originalStr.substring(left+1,right):"";
- resultStr=str.length()>resultStr.length()?str: resultStr;
- }
-
- for(int i=0;i<originalStr.length();i++){
- int left=i;
- int right=i+1;
- while (left>=0 && right<=originalStr.length()-1 && originalStr.charAt(left) == originalStr.charAt(right)){
- left--;
- right++;
- }
- String str=right-left>2?originalStr.substring(left+1,right):"";
- resultStr=str.length()>resultStr.length()?str: resultStr;
- }
- return resultStr;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。