Reported February 2024
Googletwo pointers

Stores and Houses

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 hit you with a vague title in February 2024, and that's the trap. "Stores and Houses" sounds like a graph or greedy problem, but candidates report it's actually a two-pointer or sorting challenge. You're matching stores to houses (or vice versa) and minimizing distance or maximizing coverage. The pattern isn't obvious from the name alone, which means the first 30 seconds on the problem matter. StealthCoder will read the exact prompt and surface the structure instantly, so you don't waste time guessing the category.

Pattern and pitfall

This problem boils down to optimal assignment: given two lists (stores and houses), pair them to minimize total distance or maximize some utility metric. The trick is that greedy sorting works here. Sort both lists, then use two pointers to match closest neighbors or apply a distance formula. The common pitfall is trying a brute-force pairing (all permutations) or overthinking it as a matching graph problem. In reality, a single sorted pass with index arithmetic solves it. The constraint you'll need to confirm: can a store serve multiple houses, or must pairing be one-to-one. StealthCoder reading the full problem statement will clarify that immediately, giving you the exact constraint before you code.

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 Stores and Houses 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 closest binary search tree value. 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.

Stores and Houses FAQ

What's the actual pattern here, given the vague title?+

Two-pointer on sorted arrays, or greedy assignment. Sort stores and houses by coordinate, then iterate with pointers or indices to match them optimally. The problem is not graph-based or DP, despite how it might sound. It's a simple linear scan after sorting.

Is this asking for one-to-one pairing or can stores serve multiple houses?+

The problem statement will specify. If one-to-one, two-pointer works perfectly. If one store serves many or vice versa, the logic adapts but the core is still assignment. You must read the exact constraint before coding.

How do I approach this in under 10 minutes if I blank on the name?+

Read the full problem. Identify that you have two lists and a distance or utility metric. Sort both. Use two pointers or a simple loop to assign optimally. Code a single pass, test the example, done. Don't overthink.

What's the common mistake on this one?+

Trying permutations or dynamic programming. Candidates forget that greedy sorting works perfectly when you're just minimizing distances. You don't need DP or backtracking. Sort and scan.

Is this still being asked by Google in 2024?+

Yes, as of February 2024. It's a medium-difficulty assignment problem. Not top-of-the-list hard, but the vague title trips candidates up. Knowing it's a sorting plus two-pointer problem gives you a massive edge.

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