Practice Longest Palindromic Subsequence After at Most K Operations
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Longest Palindromic Subsequence After at Most K Operations
Problem Statement
You are given a string s and an integer k. In one operation, you can replace the character at any position with the next or previous letter in the alphabet (wrapping around so that 'a' is after 'z'). For example, replacing 'a' with the next letter results in 'b', and replacing 'a' with the previous letter results in 'z'. Similarly, replacing 'z' with the next letter results in 'a', and replacing 'z' with the previous letter results in 'y'. Return the length of the longest palindromic subsequence of s that can be obtained after performing at most k operations.
Source: Longest Palindromic Subsequence After at Most K Operations on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "abced", k = 2
3
# Example 2
s = "aaazzz", k = 4
6
Constraints
Related LeetCode Problems
Practice more problems similar to Longest Palindromic Subsequence After at Most K Operations.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.