Rearranging String
Reported by candidates from Intuit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Intuit's February OA is asking you to rearrange a string, and this is exactly the kind of problem that looks simple but catches people off guard in real time. You're probably thinking it's a straightforward permutation or sorting problem, but the actual constraint is usually hidden in what "valid" means. StealthCoder is your net if the trick doesn't land immediately during the live assessment. The pattern here is pure string manipulation with a hash table underneath.
Pattern and pitfall
The rearrangement constraint is almost always about avoiding adjacent duplicates or satisfying some character frequency requirement. You'll need to count character frequencies, then greedily place the most common character first, ensuring no two identical characters sit next to each other. The core trick: if any single character appears more than (length + 1) / 2 times, no valid rearrangement exists. Many candidates miss this early check and waste time trying to construct an impossible answer. Use a max heap to always pick the most frequent available character next. The greedy approach works because you're always reducing the highest frequency bottleneck. If you blank on the heap logic during the OA, StealthCoder reads the problem and hands you the pattern in real time.
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 Rearranging String 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 reorganize string. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Intuit's OA.
Intuit 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.
Rearranging String FAQ
What does 'rearranging' actually mean in this context?+
It means you're outputting a permutation of the input string with a specific constraint. Usually that constraint is no two identical characters can be adjacent. Read the problem statement carefully for the exact rule.
Is this a sorting problem or a hash table problem?+
It's fundamentally a hash table problem (count frequencies) combined with a greedy selection strategy using a max heap. Sorting alone won't solve it because order matters structurally, not lexicographically.
How do I know if a rearrangement is impossible?+
If the most frequent character appears more than ceil(n / 2) times, where n is the string length, no valid arrangement exists. Check this first to avoid wasting time on construction.
Can I solve this in one pass or do I need multiple passes?+
You need at least two conceptual passes: one to count frequencies, one to construct the result. The construction pass uses a greedy heap-based approach. You can't do it in a single linear scan.
Is this problem still asked at Intuit or just old data?+
It was reported in February 2024, so it's recent. String rearrangement problems remain common at mid-tier companies. The specific constraint may vary, so read the full problem statement when you sit down.