leetcode palindrome-partitioning

来源:互联网 发布:美工工作流程 编辑:程序博客网 时间:2024/06/03 23:05

问题描述:

https://oj.leetcode.com/problems/palindrome-partitioning-ii/点击打开链接

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] : 字符串s[1, i]的最小cut。

初始化:

f[i] = i - 1; 最差情况分割成为独立的字符。

推导:

f[i] =  min{ f[i], f[j-1] + 1} s[j, i]是回文串。

0 0
原创粉丝点击