Remove Palindromic Subsequences Problem
Remove Palindromic Subsequences Problem — ExecCode Easy DSA Practice
Solve the Remove Palindromic Subsequences problem on ExecCode. Free online easy DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a string s consisting only of letters 'a' and 'b'. Your task is to compute the required answer and return the minimum number of steps to make the given string empty. In a single step you can remove one palindromic subsequence from s. 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.
Examples
Input {"s": "ababa"}; Output 1. Input {"s": "abb"}; Output 2
Constraints
1 <= s.length <= 1000 s[i] is either 'a' or 'b'.
Practice Remove Palindromic Subsequences free on ExecCode. Browse DSA problems, topic map, and placement guides.