Reported May 2024
Googlebinary search

Search Suggestions System

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's Search Suggestions System landed on your OA in May 2024, and it's a binary-search trap dressed as autocomplete. You're building the backend that returns prefix-matched suggestions, ranked by frequency or relevance. The trick: candidates either brute-force every prefix match or miss the sorted order constraint that makes binary search your shortcut. StealthCoder sits behind you during the live assessment, ready to unblock you if the binary-search angle goes fuzzy under pressure.

Pattern and pitfall

The pattern is binary search on a sorted trie or sorted array of suggestions. You store suggestions sorted by frequency or lexicographically, then use binary search to find the leftmost and rightmost matching prefix range. Common misfire: iterating through all suggestions for each query, which works but fails at scale. The move is to precompute or maintain sorted order, then binary-search the boundary positions. One more trap: off-by-one errors on the range boundaries. StealthCoder's real value shows here: if you blank on whether to use left-inclusive or right-inclusive bounds, you've got a reference implementation running live.

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 Search Suggestions System 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as search suggestions system. If you have time before the OA, drill that.

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

Search Suggestions System FAQ

Is this really asking for binary search, or can I just filter and sort?+

Filtering and sorting each query works for small datasets, but Google wants scale. Binary search assumes the suggestion list is pre-sorted by frequency or lexicographic order. If your solution is O(n log n) per query, you've missed the binary-search optimization that brings it to O(log n + k) where k is the result count.

Do I need a trie, or can I use a sorted list?+

Both work. A trie with sorted children is cleaner for prefix matching; a flat sorted array with binary search for prefix boundaries is simpler to code under time pressure. Choose based on your comfort. The algorithm is the same: binary search the lower and upper bounds of the prefix range.

What if two suggestions have the same frequency?+

Tie-break alphabetically or by insertion order, depending on the problem statement. Make sure your binary search respects the tie-break consistently. If you're not told, alphabetical is the safest bet at Google.

How do I handle the boundary cases in binary search?+

Use lower_bound and upper_bound logic: find the first suggestion >= prefix, and the first suggestion > prefix + 'z' (or 'z' repeated). Be careful with inclusive vs. exclusive boundaries. Off-by-one errors kill this problem.

Can I avoid binary search if I cache results?+

Caching helps if queries repeat, but Google's looking for the algorithmic insight. If the problem says 'millions of queries', caching alone won't cut it. Binary search is the expected lever.

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