Two Furthest Houses With Different Colors
A easy-tier problem at 66% community acceptance, tagged with Array, Greedy. Reported in interviews at Visa and 0 others.
You've got an array of house colors and need to find the two houses with different colors that are furthest apart. Sounds straightforward. Visa has asked this. It's marked easy with a 65% acceptance rate, which means a solid chunk of candidates are missing something or overthinking it. The trick isn't complex, but the greedy insight is what separates a clean solution from one that loops unnecessarily. If this lands in your OA and you blank on the greedy pattern, StealthCoder solves it invisibly in seconds.
Companies that ask "Two Furthest Houses With Different Colors"
Two Furthest Houses With Different Colors 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe naive instinct is to check every pair of houses and track the maximum distance where colors differ. That works but wastes time. The greedy insight: the furthest houses are always at the edges or far out. You only need to compare the colors at specific positions, not all pairs. Once you realize the answer must involve the first and last house, or positions near them, the solution collapses into a few checks. Common pitfall: candidates iterate through all pairs without recognizing that distance is maximized at the boundaries. Array iteration and Greedy are the listed topics because you're scanning for edge cases and greedily picking the largest distance. During a live assessment, if the pattern doesn't click immediately, StealthCoder reads the problem and delivers the working greedy approach without delay.
Pattern tags
You know the problem.
Make sure you actually pass it.
Two Furthest Houses With Different Colors recycles across companies for a reason. It's easy-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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Two Furthest Houses With Different Colors interview FAQ
Is this problem actually easy?+
Yes, technically. 65% acceptance rate confirms it. But easy doesn't mean obvious. Candidates often brute-force all pairs when the greedy approach is much faster. The difficulty spike comes from not recognizing the pattern, not the code itself.
What's the greedy trick?+
The furthest distance is always between houses on or near the edges. You don't need to check every pair. Identify which positions can possibly yield the maximum distance, compare colors there, and you're done. Greedy because you're directly targeting the largest possible span.
Will Visa ask this in their real interviews?+
Visa has reportedly asked this problem. It's a real OA question. It tests whether you can spot a pattern without overthinking. Prep it, understand the greedy insight, and you'll handle it calmly if it shows up.
What if I iterate all pairs?+
It still passes but wastes CPU and shows you didn't catch the optimization. In a timed assessment, inefficiency costs. Understanding the greedy insight proves you can spot structural patterns, not just brute-force. That's what Visa is likely testing.
How does Array relate to the trick?+
The problem is just an array of colors. Array iteration is your tool, but greedy logic is the key. You're not sorting or partitioning, just scanning smart positions and comparing. The two topics work together: greedy thinking simplifies which array indices you actually need to check.
Want the actual problem statement? View "Two Furthest Houses With Different Colors" on LeetCode →