LC 1332. Remove Palindromic Subsequences

Nilanjan Deb · April 5, 2020

This is my CPP solution.

class Solution {
private:
    bool palindrome(string s){
        int n = s.size();
        for(int i=0;i<n/2;i++)
            if(s[i]!=s[n-i-1])
                return false;
        return true;
    }
public:
    int removePalindromeSub(string s) {
        if(s.size()==0)
            return 0;
        if(palindrome(s))
            return 1;
        return 2;
    }
};


Dicussion Forum