Minimum insertions to form a palindrome
来源:互联网 发布:图书数据哪个网站多 编辑:程序博客网 时间:2024/06/13 22:18
相关问题1:最长回文子串
相关问题2:[LeetCode] Shortest Palindrome I
给你一个字符串S,插入一些字符,把 S 转换成一个回文字符串。
例如:
ab: Number of insertions required is 1. bab
aa: Number of insertions required is 0. aa
abcd: Number of insertions required is 3. dcbabcd
abcda: Number of insertions required is 2. adcbcda which is same as number of insertions in the substring bcd
思路:可以用递归的方法。
The minimum number of insertions in the string str[l…..h] can be given as:
minInsertions(str[l+1…..h-1]) if str[l] == str[h]
min(minInsertions(str[l…..h-1]), minInsertions(str[l+1…..h])) + 1 if str[l] != str[h]
0 0
- Minimum insertions to form a palindrome
- DP28 求能变成回文的最小插入字符个数 Minimum insertions to form a palindrome @geeksforgeeks
- uva 10716 - Minimum Swap to form Palindrome
- HDU: 4731 Minimum palindrome
- HDU-4731-Minimum palindrome
- HDU 4731 Minimum palindrome
- HDOJ 4731 Minimum palindrome
- HDU 4731 Minimum Palindrome
- HDU 4731 Minimum palindrome
- How to Submit a Form Using JavaScript
- Resizing a Form to Fit an Image
- How to make a child form listen to broadcasted messages
- How to stretch a background image of a windows form
- Probability to form a triangle by splitting a stick
- Convert it to a sorted array with minimum cost
- hdu 4731 Minimum palindrome(构造)
- 2.7 Implement a function to check if a linked list is a palindrome
- How to simulate a Form POST request by using WinInet
- Mac上Android手机无法连接解决方案
- Sending iOS Push Notifications via APNS in JavaScript
- [译]CasperJS,基于PhantomJS的工具包
- 文章19:Nginx中为http请求或响应添加头部字段
- 从优化到再优化,最长公共子串
- Minimum insertions to form a palindrome
- githubslidingmenu
- 课堂笔记08
- Search in Rotated Sorted Array II
- MySQL Index详解
- Linux系统内核性能调优
- Android 编程权威指南 阅读笔记
- C#高级编程六十四天----并行扩展
- QT快捷键