当前位置:网站首页>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;
}
}
边栏推荐
- 2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination
- [human version] Web3 privacy game in the dark forest
- Haskell lightweight threads overhead and use on multicores
- Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记
- Use winmtr software to simply analyze, track and detect network routing
- 测量三相永磁同步电机的交轴直轴电感
- TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.2 多属性注册协议(Multiple Registration Protocol (MRP))
- [pat (basic level) practice] - [simple simulation] 1064 friends
- Threejs opening
- 总结全了,低代码还需要解决这4点问题
猜你喜欢

使用WinMTR软件简单分析跟踪检测网络路由情况

2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities

Simple implementation of slf4j

Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling

How to use maixll dock

离线安装wireshark2.6.10

OdeInt与GPU

Maixll dock quick start

Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor
![[leetcode skimming] February summary (updating)](/img/62/0d0d9f11434e49d33754a2e4f2ea65.jpg)
[leetcode skimming] February summary (updating)
随机推荐
离线安装wireshark2.6.10
The index is invalid
Tcp/ip explanation (version 2) notes / 3 link layer / 3.4 bridge and switch / 3.4.2 multiple registration protocol (MRP)
What are permissions? What are roles? What are users?
The junior college students were angry for 32 days, four rounds of interviews, five hours of soul torture, and won Ali's offer with tears
【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
Programs and processes, process management, foreground and background processes
2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
js 图片路径转换base64格式
CF1638E. Colorful operations Kodori tree + differential tree array
LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
Knowledge supplement: redis' basic data types and corresponding commands
Codeworks round 449 (Div. 1) C. Kodori tree template
About the transmission pipeline of stage in spark
【硬十宝典】——1.【基础知识】电源的分类
OdeInt與GPU
OSPF notes [multiple access, two multicast addresses with OSPF]
Question bank and answers for chemical automation control instrument operation certificate examination in 2022
One click shell to automatically deploy any version of redis
【LeetCode】100. Same tree