You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.

Return the minimum number of steps to make the given string empty.

A string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.

A string is called palindrome if is one that reads the same backward as well as forward.

&nbsp;
Example 1:

Input: s = "ababa"
Output: 1
Explanation: s is already a palindrome, so its entirety can be removed in a single step.


Example 2:

Input: s = "abb"
Output: 2
Explanation: "abb" -&gt; "bb" -&gt; "". 
Remove palindromic subsequence "a" then "bb".


Example 3:

Input: s = "baabb"
Output: 2
Explanation: "baabb" -&gt; "b" -&gt; "". 
Remove palindromic subsequence "baab" then "b".


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 1000
	s[i] is either 'a' or 'b'.


class Solution:
    def removePalindromeSub(self, s: str) -> int:
        return 1 if s[::-1] == s else 2
        
class Solution
{
    public int removePalindromeSub(String s)
    {
        int left = 0 , right = s.length() - 1 ;
        while( left < right )
        {
            if( s.charAt(left++) != s.charAt(right--) )
            {
                return 2 ;
            }
        }
        return 1 ;
    }
}
  //the major obersavation or we can also verify by giving your own test it always returns 1 or 2 
    //if the whole string is palindrom then return 1 if not then return 2.
class Solution {
   static bool isPal(string s){
        string p = s;
        reverse(p.begin() , p.end());
       return s==p;     
    }
public:
    int removePalindromeSub(string s) {
  
        if(isPal(s)){
            return 1;
        } 
        
        return 2;
    }
};
var removePalindromeSub = function(s) {
    const isPalindrome = s == s.split('').reverse().join('');
    return isPalindrome ? 1 : 2;
};
Remove Palindromic Subsequences