Reported April 2024
Googlesorting

Split and Sort

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google asked this in April 2024 and it's a sorting problem that looks deceptively simple on the surface. You get a string or array, split it some way, then sort the pieces. The trap is figuring out what "sort" actually means here. Are you sorting lexicographically, numerically, by length, by frequency? The problem title won't tell you. You need to infer the sort order from examples or constraints. StealthCoder will read the problem live and spot the sort key instantly if you blank on what the expected output should be.

Pattern and pitfall

Split and Sort is testing whether you can parse an underspecified problem and implement the right comparator. The algorithmic meat is straightforward: tokenize the input, apply a custom sort, return the result. What kills candidates is misreading the sort order or not handling edge cases like empty strings, whitespace, or duplicate values. The pattern is sorting with a non-obvious key. You'll likely use a language's built-in sort with a custom comparator or lambda. Common pitfalls include sorting in the wrong order (ascending vs descending) or forgetting to handle tied elements. When you hit the OA and the examples don't immediately clarify the sort rule, StealthCoder will spotlight the exact comparison function you need.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Split and Sort 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google 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.

Split and Sort FAQ

Is this a string or array problem?+

Could be either. Google doesn't always specify upfront. The key is reading the examples carefully. If you see single words being split, it's string manipulation. If you see a list of numbers, it's array sorting. The underlying pattern remains the same: tokenize, sort by the right key, return.

What's the most common sorting key Google tests here?+

Lexicographic (alphabetical) order is the default. But watch for length-based sorting or frequency-based sorting as a twist. The problem statement will hint at it in the examples. Don't assume ascending order without checking the expected output direction.

How do I figure out the sort key if the problem is vague?+

Look at the examples. Sort the first example by every plausible key: alphabetically, reverse alphabetically, by length, by frequency. Match the expected output. That's your key. If there's no example, the problem is poorly written, but Google usually includes at least one test case that makes it clear.

What edge cases should I handle?+

Empty strings after splitting, whitespace-only tokens, single-character elements, duplicates (do they stay in input order or get deduplicated?), and case sensitivity (uppercase vs lowercase). Test each locally before submitting.

Can I solve this in under 15 minutes?+

Yes, if you nail the sort key. The split and sort itself is 3-5 lines of code. The hard part is reading the problem correctly and choosing the right comparator. Spend 2 minutes on examples, 1 minute coding, 2 minutes testing edge cases.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it