MEDIUMasked at 2 companies

As Far from Land as Possible

A medium-tier problem at 52% community acceptance, tagged with Array, Dynamic Programming, Breadth-First Search. Reported in interviews at UiPath and 1 others.

Founder's read

You're staring at a grid where every cell is either land or water, and you need to find the spot farthest from any shore. UiPath and Wix have both asked this. It's a medium-difficulty problem that looks simple until you realize the brute-force approach tanks on larger grids. The real solution requires BFS to compute distance layers from all land cells simultaneously, not just one-off distance checks. If this problem appears in your live OA and you blank on the multi-source BFS pattern, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
52%

Companies that ask "As Far from Land as Possible"

If this hits your live OA

As Far from Land as Possible 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

The trap here is thinking single-source. You're not finding the farthest point from one land cell; you're finding the point farthest from the nearest land cell. That's a completely different problem. The pattern is multi-source BFS: enqueue all land cells at once, then expand outward layer by layer, marking distances as you go. Water cells get visited in order of their minimum distance to any land. The obvious greedy or DP approach collapses because you need to explore from all shores simultaneously. Common pitfall: iterating BFS from each land cell separately, which is O(n^2 m^2) and slow. The correct approach is O(nm) because each cell gets visited once. If you haven't drilled the multi-source pattern before, StealthCoder catches this trick instantly during the assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

As Far from Land as Possible 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 because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

As Far from Land as Possible interview FAQ

Is this really medium, or is it harder than it looks?+

The acceptance rate sits around 52%, which is standard for medium. The gap between recognizing it's a distance problem and knowing to use multi-source BFS is where candidates stumble. Once you see the pattern, it's straightforward code.

Do I need dynamic programming for this?+

No. DP is listed as a related topic, but the optimal solution is pure multi-source BFS. You could theoretically DP the distance grid after BFS, but BFS alone solves it. DP might appear in suboptimal approaches candidates try first.

How does this relate to 'surrounded regions' or 'number of islands'?+

All three are matrix traversal problems, but the key difference is goal. Islands count components. Surrounded regions check connectivity from edges. This one measures distance from all land to all water simultaneously. BFS is common to all, but multi-source is specific to distance-from-all problems.

Will this actually show up if I interview at UiPath or Wix?+

Both companies have reportedly asked it. At 52% acceptance, it's not rare, but not guaranteed either. It's the kind of problem that fits their backend and platform interview loops, so it's worth drilling if you're targeting either.

What's the most common mistake candidates make?+

Running single-source BFS from the farthest land cell, or trying to grid-search and check distances manually. Both are O(n^2 m^2) or worse. Candidates also forget to enqueue all land cells at the start, losing the 'all sources at once' insight that makes the algorithm work.

Want the actual problem statement? View "As Far from Land as Possible" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.