Rearrange Words in a Sentence
A medium-tier problem at 66% community acceptance, tagged with String, Sorting. Reported in interviews at Expedia and 0 others.
You're prepping for Expedia or another online assessment, and you hit a string manipulation problem that sounds deceptively simple: rearrange words in a sentence. The trick isn't the rearrangement itself. It's recognizing that the obvious string split-and-sort approach works, but only if you understand what "rearrange" really means in context. With a 66% acceptance rate, this problem catches people who overthink it or miss the exact output format. If this one lands in your live OA and you blank on the implementation details, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Rearrange Words in a Sentence"
Rearrange Words in a Sentence 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 by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe core pattern is basic: split the sentence into words, sort them, and join them back. Most solutions nail this in a few lines. The real pitfall is output format. Some versions ask you to reverse word order (common trick), others ask alphabetical sorting. You need to read the problem statement carefully and test your assumption against examples. Edge cases like leading/trailing spaces, multiple spaces between words, or single-word inputs catch careless submissions. String and Sorting are the only topics here, which means brute force works fine. The 66% acceptance suggests people submit without testing edge cases or misunderstand the exact rearrangement rule. If you hit this during assessment and the expected output doesn't match your logic, StealthCoder surfaces a passing solution immediately so you don't lose 15 minutes debugging.
Pattern tags
You know the problem.
Make sure you actually pass it.
Rearrange Words in a Sentence 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 by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Rearrange Words in a Sentence interview FAQ
Is this problem actually as easy as split, sort, and join?+
Mostly yes. The algorithm is straightforward. The catch is the output format. Some versions want alphabetical sort, others reverse order. You must match the exact expected output. That 66% acceptance rate reflects people who skip careful testing or misread the requirement, not algorithmic difficulty.
What's the trick that catches people on this one?+
Handling whitespace. Multiple spaces between words, trailing spaces, or leading spaces can trip you up. Also verify whether the problem wants alphabetical or reverse-order sorting. Read the examples closely. The algorithm itself won't fail you, the spec will.
Does Expedia really ask this?+
Yes, Expedia is listed as the primary reported company. It's a medium-difficulty problem, so you'll see it in screening rounds or take-home assessments. Not a hard problem, but you need to execute cleanly.
Is this still a live OA question or just a practice problem?+
It appears in real assessments. Expedia and similar companies use string and sorting fundamentals to filter candidates quickly. It's not a trick problem, but botching output format or edge cases will fail you.
How do I know if I got the right answer?+
Test against multiple examples, especially ones with irregular spacing or single words. If your output matches the expected format exactly (including whitespace), you're good. The 66% acceptance suggests most failures are output mismatch, not logic.
Want the actual problem statement? View "Rearrange Words in a Sentence" on LeetCode →