MEDIUMasked at 1 company

Can Make Palindrome from Substring

A medium-tier problem at 40% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Akuna Capital and 0 others.

Founder's read

Can Make Palindrome from Substring hits different when you realize it's not about building palindromes at all. Akuna Capital has asked it, and the 40% acceptance rate reflects a trick most candidates miss on first read. You're given a string and a list of queries, each asking whether a substring can be rearranged into a palindrome. The naive approach (check each query in isolation) times out. The pattern lies in understanding what makes a palindrome possible, then encoding that insight into a prefix structure you can query in constant time.

Companies asking
1
Difficulty
MEDIUM
Acceptance
40%

Companies that ask "Can Make Palindrome from Substring"

If this hits your live OA

Can Make Palindrome from Substring 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. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

A string can be rearranged into a palindrome if and only if at most one character has an odd frequency. Most candidates start by computing character frequencies for each query substring, which is O(n) per query and fails on large inputs. The real move is precomputing a bitmask for each prefix, where each bit represents the parity (odd or even count) of a character. XOR these masks: any substring's character parities are revealed instantly by XORing the prefix masks at its boundaries. If the result has one or zero bits set (at most one odd-frequency character), that substring works. Bit Manipulation and Prefix Sum are your tactical tools here. If this problem surfaces during your live OA and the prefix-XOR pattern doesn't click, StealthCoder delivers the solution invisibly while you think through implementation.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Can Make Palindrome from Substring recycles across companies for a reason. It's medium-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. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Can Make Palindrome from Substring interview FAQ

Why does the naive frequency-count approach fail?+

Recomputing character frequencies for every query substring is O(n) per query. With many queries, that's O(q * n), which exceeds time limits on large inputs. Prefix masks let you answer any query in O(1) after O(n) preprocessing.

What's the intuition behind the bitmask trick?+

Each bit in a bitmask tracks whether a character's count is odd (1) or even (0). XORing two bitmasks gives you the combined parity. For a substring from index i to j, XOR the prefix mask at j with the prefix mask at i-1 to instantly see parities for that range.

How do I know when a substring can form a palindrome?+

Count the number of set bits (1s) in the substring's XOR result. If that count is 0 or 1, the substring can be rearranged into a palindrome, because at most one character has an odd frequency.

Is this still asked at top firms like Akuna Capital?+

Yes. Akuna Capital has reported it, and the 40% acceptance rate suggests many candidates underestimate its reach. It tests both algorithmic insight and prefix-optimization thinking, both valuable interview signals.

What's the difference between this and classic bit-manipulation problems?+

This combines Bit Manipulation with Prefix Sum. You're not just manipulating bits; you're precomputing prefix states to enable O(1) range queries. It's a multi-topic blend that catches candidates who drill only one pattern.

Want the actual problem statement? View "Can Make Palindrome from Substring" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.