首页 > 其他 > 详细

[LeetCode] Palindrome Partitioning II

时间:2014-07-19 19:16:12      阅读:292      评论:0      收藏:0      [点我收藏+]

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",
Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.

 

定义状态 f(i,j) 表示区间 [i,j] 之间最小的 cut 数,则状态转移方程为
f(i, j) = min { f(i, k) + f(k + 1, j) } , i  <=k <= j, 0 < i <=  j <= n

 

我们求解的是整个字符串的最小cut数,可以从字符串的头开始,也可以从尾部开始

[LeetCode] Palindrome Partitioning II,布布扣,bubuko.com

[LeetCode] Palindrome Partitioning II

原文:http://www.cnblogs.com/diegodu/p/3853537.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!