# Remove palindromic subsequence


LeetCode Problem: https://leetcode.com/problems/remove-palindromic-subsequences/submissions/

Problem Statement : Remove Palindrome Subsequence 

We have String s which is a combination of two letters ‘a’ and ‘b’. We have to remove palindromic subsequence.

What is a palindrome?
A string that reads the same from back and forth. Like: “WOW”

What is the subsequence of string?
A string is a subsequence of a given string if it contains the same character available in the string. Here, order matters. That means characters must be available in the same order as they are available in string.


Back to a problem

So, in this problem, we have to remove the subsequence which is palindrome, and the subsequence which is left behind in the string.
It has clearly been mentioned that removing one palindromic subsequence from a string requires a single step.

For example:

Input : s = “aabba”
Here, there is one longest palindromic sequence and one non-palindromic
i.e. “abba” and “a”

Output: 2 
So, to remove all subsequences from the string takes two steps. First, remove palindromic subsequence + remove non- palindromic subsequence


Input: s=“abb”
Now, s is a palindrome in nature
So it takes a single step to remove from s string

Output: 1


So the logic we are likely to apply is :

If the string is palindrome then it returns 1
If the string is empty i.e. having no element in it then it returns 0
Else
Returns 2

Code: in JAVA, Be happy to use any other prefer oop language:
```
class Solution {
    public int removePalindromeSub(String s) {
        if(s.isEmpty()){
            return 0;
        }
        if(checkPalindrome(s)){
            return 1;
        }
        return 2;
        
    }
    private boolean checkPalindrome(String s){
        int i=0;
        int j=s.length() -1;
        
        while(i<j){
            if(s.charAt(i)==s.charAt(j)){
                i++;
                j--;
                
            }
            else{
                return false;
            }
        }
        return true;
    }
}
```

