标签:length solution turn java har art log new logs
class Solution { public int minCut(String s) { int[] dp=new int[s.length()+1]; for(int i=0;i<=s.length();i++) dp[i]=i-1; for(int i=1;i<s.length();i++) { for(int len=0;i-len>=0&&i+len<s.length()&&s.charAt(i-len)==s.charAt(i+len);len++) dp[i+1+len]=Math.min(dp[i+1+len],dp[i-len]+1); for(int len=0;i-1-len>=0&&i+len<s.length()&&s.charAt(i-1-len)==s.charAt(i+len);len++) dp[i+1+len]=Math.min(dp[i+1+len],dp[i-1-len]+1); } return dp[s.length()]; } }
132. Palindrome Partitioning II
标签:length solution turn java har art log new logs
原文地址:http://www.cnblogs.com/asuran/p/7628166.html