20、 palindrome-partitioning-ii
给出一个字符串s,分割s使得分割出的每一个子串都是回文串
计算将字符串s分割成回文分割结果的最小切割数
例如:给定字符串s=“aab”,
返回1,因为回文分割结果[“aa”,“b”]是切割一次生成的。
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s =“aab”,
Return1since the palindrome partitioning[“aa”,“b”]could be produced using 1 cut.
思路:使用动态规划法,设计数组min[s.length()-1],min[i]用来表示s(0,i)的最小分割次数,数组dp[j][i]判断s(j,i)是否为回文串。