当前位置:网站首页>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;
}
}
边栏推荐
- CF1638E. Colorful operations Kodori tree + differential tree array
- TASK04|数理统计
- 2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination
- js 图片路径转换base64格式
- Dual contractual learning: text classification via label aware data augmentation reading notes
- Shell analysis server log command collection
- Shell之一键自动部署Redis任意版本
- JS image path conversion Base64 format
- How to do the performance pressure test of "Health Code"
- LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
猜你喜欢

Knowledge supplement: basic usage of redis based on docker

尺取法:有效三角形的个数

Knowledge supplement: redis' basic data types and corresponding commands

Research on medical knowledge atlas question answering system (I)

How to do the performance pressure test of "Health Code"

206. reverse linked list

Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and

Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记

How to use maixll dock

2022 hoisting machinery command registration examination and hoisting machinery command examination registration
随机推荐
Why is Internet thinking not suitable for AI products?
[pat (basic level) practice] - [simple simulation] 1064 friends
Pytorch(三) —— 函数优化
(12) Somersault cloud case (navigation bar highlights follow)
Account sharing technology enables the farmers' market and reshapes the efficiency of transaction management services
Annual inventory review of Alibaba cloud's observable practices in 2021
1. Mobile terminal touch screen event
Common interview questions ①
软件研发的十大浪费:研发效能的另一面
使用WinMTR软件简单分析跟踪检测网络路由情况
One job hopping up 8K, three times in five years
CF1638E. Colorful operations Kodori tree + differential tree array
Leetcode learning - day 36
CUDA development and debugging tool
Registration for R2 mobile pressure vessel filling test in 2022 and R2 mobile pressure vessel filling free test questions
Seven crimes of counting software R & D Efficiency
2022年煤气考试题库及在线模拟考试
Talk about testdeploy
Openresty rewrites the location of 302
PgSQL failed to start after installation