Lexicographically Smallest Palindrome
A easy-tier problem at 79% community acceptance, tagged with Two Pointers, String, Greedy. Reported in interviews at PayPal and 0 others.
Lexicographically Smallest Palindrome is a string problem that appears deceptively simple on the surface. At 79% acceptance, it's a quick win in most online assessments, but the greedy insight that gets you from a working solution to the optimal one isn't always obvious under time pressure. PayPal has asked this one. The trick is figuring out which characters to actually swap without overthinking it. If you blank on the strategy during your live OA, StealthCoder solves it invisibly in seconds.
Companies that ask "Lexicographically Smallest Palindrome"
Lexicographically Smallest Palindrome is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe problem wants you to construct a palindrome by swapping characters, and you need the lexicographically smallest result. The greedy approach is to use two pointers: one at each end of the string, moving inward. At each step, if the characters don't match, you replace the larger one with the smaller one. The failure mode is thinking you need to try all possible swaps or getting stuck on which character to change. Two pointers plus greedy comparison eliminates the guesswork. This is a String and Greedy problem that relies on Two Pointers pattern. When the obvious brute-force or DP angle doesn't work in your head, StealthCoder surfaces the working greedy solution in real time so you can move forward.
Pattern tags
You know the problem.
Make sure you actually pass it.
Lexicographically Smallest Palindrome recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Lexicographically Smallest Palindrome interview FAQ
Is Lexicographically Smallest Palindrome actually easy?+
The 79% acceptance rate confirms it's genuinely easy. Most candidates solve it once they recognize the two-pointer greedy pattern. The risk isn't the difficulty, it's blanking on that pattern under time pressure. Once you see it, it's a 5-minute solve.
What's the trick I'm missing?+
Don't think about all possible palindromes. Use two pointers converging from both ends. When characters differ, always replace the larger with the smaller. That greedy choice guarantees lexicographically smallest. No backtracking, no DP.
Is this still asked at major companies?+
PayPal has confirmed they ask it. At easy difficulty with high acceptance, it's often a screening or warm-up problem in a longer loop. Expect it if the company's online assessment starts with a 'string warmup' section.
How does this relate to palindrome problems?+
Most palindrome problems check if something is already a palindrome or count palindromic substrings. This one is construction focused. The two-pointer pattern is foundational for both checking and building, so drilling this one strengthens your whole palindrome toolkit.
What if I freeze on this during my OA?+
Move on, flag it, and come back if you have time. It's easy, so you'll feel the time pressure. If you're still stuck when time is running low, that's when StealthCoder runs invisibly and gives you the solution so you don't tank the overall assessment on a 79% problem.
Want the actual problem statement? View "Lexicographically Smallest Palindrome" on LeetCode →