Tap here to switch tabs
Problem
Submissions

Problem: Remove Palindromic Subsequences

med
30 min
Try to solve the Remove Palindromic Subsequences problem.

Statement

You are given a string s consisting only of the characters 'a' and 'b'.

In a single operation, you can remove any palindromic subsequence from s.

Return the minimum number of operations required to make s completely empty.

Note: A subsequence is derived from a string by deleting 00 or more characters without altering the relative order of the remaining characters. A string is considered a palindrome if it reads identically from left to right and from right to left.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s[i] is either 'a' or 'b'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Remove Palindromic Subsequences

med
30 min
Try to solve the Remove Palindromic Subsequences problem.

Statement

You are given a string s consisting only of the characters 'a' and 'b'.

In a single operation, you can remove any palindromic subsequence from s.

Return the minimum number of operations required to make s completely empty.

Note: A subsequence is derived from a string by deleting 00 or more characters without altering the relative order of the remaining characters. A string is considered a palindrome if it reads identically from left to right and from right to left.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s[i] is either 'a' or 'b'.