Palindrome Partitioning II
来源:互联网 发布:梅雨知时节的作品 编辑:程序博客网 时间:2024/05/29 17:04
public class Solution { public int minCut(String s) { if (s == null || s.length() == 0) { return 0; } int length = s.length(); boolean[][] isPalindrome = new boolean[length][length]; int[] cut = new int[length]; for (int j = 0; j < length; j++) { cut[j] = j; for (int i = 0; i <= j; i++) { if (s.charAt(i) == s.charAt(j) && (j - i <= 1 || isPalindrome[i + 1][j - 1])) { isPalindrome[i][j] = true; if (i == 0) { cut[j] = 0; } else { cut[j] = Math.min(cut[j], cut[i - 1] + 1); } } } } return cut[length - 1]; }}
0 0
- LeetCode : Palindrome Partitioning II
- [leetcode] Palindrome Partitioning II
- leetcode:Palindrome Partitioning II
- Palindrome Partitioning II
- 【leetcode】Palindrome Partitioning II
- Palindrome Partitioning II
- leetcode - Palindrome Partitioning II
- Palindrome Partitioning II
- Palindrome Partitioning II
- [LeetCode]Palindrome Partitioning II
- [Leetcode]Palindrome Partitioning II
- [leetcode]Palindrome Partitioning II
- Palindrome Partitioning II
- leetcode Palindrome Partitioning II
- Palindrome Partitioning II
- LetCode:Palindrome Partitioning II
- LeetCode-Palindrome Partitioning II
- [leetcode] Palindrome Partitioning II
- Zen Garden驾到:首批Metal游戏已登录iTunes应用商店
- springmvc 前端控制器,映射器,适配器,视图解析器
- python实现单词计数的mapreduce
- Metal Framework Reference
- CSS中的变量使用详解
- Palindrome Partitioning II
- java中的debug使用
- Node.js开发入门—Express里的路由和中间件
- SAP固定资产期初导入检查
- 【C++基础之一】C++ 虚函数表解析
- k780数据解析测试
- uva 10474
- 时光切片—我是海康人
- HDU 5316 Magician(线段树 区间合并)