Validate a Palindrome After Limited Deletions
Reported by candidates from Meta's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Meta OA, reported in August 2026, is treating it like Valid Palindrome II and greedily skipping one side on a mismatch. With k deletions allowed, that greedy call breaks. You're given a string s and a nonnegative k, and you must say whether deleting at most k characters makes s a palindrome. It looks like two pointers. It's really a DP problem wearing a two-pointer costume. If you've got the invite and 48 hours, learn the recurrence below. StealthCoder is the safety net running invisibly during the live OA if your mind goes blank.
The problem
Given a string s and a nonnegative integer k, return true if deleting at most k characters can make s a palindrome. The remaining characters keep their original order. The empty string and every one-character string are palindromes. Character comparisons are case-sensitive. Function isValidPalindrome(s: String, k: int) → boolean Examples Example 1 s = "abca" k = 1 return = true Delete either b or c to obtain a palindrome. Example 2 s = "abcdeca" k = 2 return = true Deleting b and e leaves acdca. Example 3 s = "abc" k = 1 return = false Deleting one character leaves two different characters. Constraints k is nonnegative. s may be empty. The input is compared as a sequence of case-sensitive characters.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: deleting at most k characters to get a palindrome means the minimum deletions needed is n minus the length of the longest palindromic subsequence. So compute LPS and check n - LPS <= k. Equivalently, define dp[i][j] as min deletions to make s[i..j] a palindrome. If s[i] equals s[j], it's dp[i+1][j-1]. Otherwise it's 1 + min(dp[i+1][j], dp[i][j-1]). The pitfall is the greedy two-pointer that, on a mismatch, tries only one skip and moves on. That works for k=1 with a check of both branches, but for larger k, naive branching explodes without memoization. Watch the base cases too: empty and single-character strings need zero deletions, and comparisons are case-sensitive. Space can drop to O(n) with a rolling row. If you freeze live, StealthCoder can hand you the recurrence while you type.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Validate a Palindrome After Limited Deletions cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as valid palindrome iii. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Meta's OA.
Meta reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Validate a Palindrome After Limited Deletions FAQ
What's the trick for this Meta palindrome deletion problem?+
Minimum deletions equals n minus the longest palindromic subsequence. Compute the LPS with interval DP, then return whether n - LPS is at most k. You can also define dp[i][j] as the minimum deletions for the substring directly. Both give O(n^2) time.
Why doesn't a simple two-pointer greedy work?+
On a mismatch you don't know which side to delete. For k=1 you can check both branches. For larger k, committing to one side gives wrong answers. You need DP or memoized recursion that tries both skips and takes the minimum.
How is this different from Valid Palindrome II?+
Valid Palindrome II allows exactly at most one deletion, so two pointers with a single branch point is enough. Here k is arbitrary, so the branching compounds and you need memoization or a full DP table to stay polynomial.
Which edge cases should I test before submitting?+
Test the empty string, a single character, k=0 on a non-palindrome, and k at least n. Also test mixed case like 'aA', since comparisons are case-sensitive. Confirm your base case returns zero deletions when i is at least j.
How do I prepare for this in 48 hours?+
Write the LPS interval DP from scratch twice. Then write the min-deletions version and compare answers on the three examples. Practice the rolling-array space optimization if you have time. Skip fancy variants. This one recurrence covers the whole problem.