Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindromic Subsequence After K Operations

Try to solve the Longest Palindromic Subsequence After at Most K Operations problem.

Statement

You are given a string s and an integer k.

In a single operation, you can choose any character in s and change it to either the previous or the next character in the circular alphabet (where 'a' transitions to 'z' and 'z' transitions to 'a').

Return the maximum possible length of a palindromic subsequence that can be obtained from s after applying at most k total operations.

Note: A subsequence is a string derived from another string by deleting zero or more characters without changing the order of the remaining characters.

Constraints:

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

  • 1≤1 \leq k ≤200\leq 200

  • s consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindromic Subsequence After K Operations

Try to solve the Longest Palindromic Subsequence After at Most K Operations problem.

Statement

You are given a string s and an integer k.

In a single operation, you can choose any character in s and change it to either the previous or the next character in the circular alphabet (where 'a' transitions to 'z' and 'z' transitions to 'a').

Return the maximum possible length of a palindromic subsequence that can be obtained from s after applying at most k total operations.

Note: A subsequence is a string derived from another string by deleting zero or more characters without changing the order of the remaining characters.

Constraints:

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

  • 1≤1 \leq k ≤200\leq 200

  • s consists of only lowercase English letters.