---
# System prepended metadata

title: 1332. Remove Palindromic Subsequences
tags: [Leetcode, Bloomberg, Easy]

---

# 1332. Remove Palindromic Subsequences
###### tags: `Leetcode` `Easy` `Bloomberg`
Link: https://leetcode.com/problems/remove-palindromic-subsequences/
## 思路
注意这里的字串只有a跟b
所以只会有两种结果
如果s是空的，ans = 0
如果字串是palindrome， ans = 1
如果不是的话，一次把a全删了，一次把b全删了
## FollowUp

## Code
```java=
class Solution {
    public int removePalindromeSub(String s) {
        if(s.length()==0) return 0;
        int start = 0;
        int end = s.length()-1;
        boolean isPalindrome = true;
        while(start<end){
            if(s.charAt(start)!=s.charAt(end)){
                isPalindrome = false;
                break;
            }
            start++;
            end--;
        }
        if(isPalindrome){
            return 1;
        }
        else{
            return 2;
        }
    }
}
```