当前位置:网站首页>Leecode question brushing record 1332 delete palindrome subsequence
Leecode question brushing record 1332 delete palindrome subsequence
2022-07-01 04:41:00 【Why is there a bug list】
topic
Give you a string s, It's just made up of letters ‘a’ and ‘b’ form . Every delete operation can be done from s Delete a palindrome in Subsequence .
Returns to delete all characters in a given string ( The string is empty ) The minimum number of deletions .
「 Subsequence 」 Definition : If a string can be obtained by deleting some characters of the original string without changing the order of the original characters , So this string is a subsequence of the original string .
「 Palindrome 」 Definition : If a string is read backward and forward the same , So this string is a palindrome .
Example 1:
Input :s = “ababa”
Output :1
explain : The string itself is a palindrome sequence , Just delete once .
Example 2:
Input :s = “abb”
Output :2
explain :“abb” -> “bb” -> “”.
First delete the palindrome subsequence “a”, And then delete it “bb”.
Example 3:
Input :s = “baabb”
Output :2
explain :“baabb” -> “b” -> “”.
First delete the palindrome subsequence “baab”, And then delete it “b”.
Tips :
1 <= s.length <= 1000
s Just letters ‘a’ and ‘b’
answer
class Solution {
public int removePalindromeSub(String s) {
if("".equals(s)) return 0;
if(new StringBuffer(s).reverse().toString().equals(s)) return 1;
return 2;
}
}
边栏推荐
- 206. reverse linked list
- 尺取法:有效三角形的个数
- LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
- 2022年G1工业锅炉司炉特种作业证考试题库及在线模拟考试
- CUDA development and debugging tool
- Caijing 365 stock internal reference | the first IPO of Beijing stock exchange; the subsidiary of the recommended securities firm for gambling and gambling, with a 40% discount
- 【LeetCode】100. Same tree
- OSPF notes [multiple access, two multicast addresses with OSPF]
- 什么是uid?什么是Auth?什么是验证器?
- Shell之Unix运维常用命令
猜你喜欢
![[learn C and fly] S1E20: two dimensional array](/img/68/34fad73ff23d3e0719ef364fc60cb5.jpg)
[learn C and fly] S1E20: two dimensional array

Annual inventory review of Alibaba cloud's observable practices in 2021

slf4j 简单实现

2022年煤气考试题库及在线模拟考试

Offline installation of Wireshark 2.6.10

VR线上展览所具备应用及特色

Daily algorithm & interview questions, 28 days of special training in large factories - the 13th day (array)

Use winmtr software to simply analyze, track and detect network routing

Pytorch(二) —— 激活函数、损失函数及其梯度

Daily question - line 10
随机推荐
CF1638E colorful operations
JS image path conversion Base64 format
Shell之Unix运维常用命令
Pytorch(三) —— 函数优化
After many job hopping, the monthly salary is equal to the annual salary of old colleagues
测量三相永磁同步电机的交轴直轴电感
One click shell to automatically deploy any version of redis
Why is Internet thinking not suitable for AI products?
Leetcode learning - day 36
Why is Hong Kong server most suitable for overseas website construction
OdeInt與GPU
Software testing needs more and more talents. Why do you still not want to take this path?
【硬十宝典】——1.【基础知识】电源的分类
Shell analysis server log command collection
C language games (I) -- guessing games
TASK04|數理統計
Research on medical knowledge atlas question answering system (I)
The design points of voice dialogue system and the importance of multi round dialogue
什么是权限?什么是角色?什么是用户?
2022年化工自动化控制仪表操作证考试题库及答案