FastPrepXiangqi Horse Reachability
Problems/Xiangqi Horse Reachability

Xiangqi Horse Reachability

eBay logoeBay● MediumPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a Xiangqi horse task with obstacles and blocked horse legs. It does not say how the board is modeled, how coordinates work, how the path is built, or what the output looks like. Our version is about 74% the same as the reported question.

You control one horse on a standard Xiangqi board with 10 rows and 9 columns. A position is written as [row, column], using zero-based coordinates.

The horse may make any number of moves. Each move travels two cells along one axis and one cell along the other axis. Before reaching its destination, the horse passes an orthogonally adjacent horse-leg square in the direction of the two-cell part of the move.

A move is legal only when all of these conditions hold:

  • The destination is inside the board.
  • The destination is not an obstacle.
  • The horse-leg square is not an obstacle.

Given start, target, and all obstacles, return true if some legal sequence of moves reaches target. Otherwise, return false.

Function

canHorseReach(start: int[], target: int[], obstacles: int[][]) → boolean

Examples

Example 1

start = [0,0]target = [2,1]obstacles = []return = true

The horse can move directly from [0,0] to [2,1]. Its horse-leg square is [1,0], which is free.

Example 2

start = [0,0]target = [2,1]obstacles = [[1,0],[0,1]]return = false

From the corner, every in-bounds move uses either [1,0] or [0,1] as its horse-leg square. Both squares are obstacles, so the horse cannot make any move.

Example 3

start = [0,0]target = [2,1]obstacles = [[1,0]]return = true

The obstacle at [1,0] blocks the direct move, but a detour remains: [0,0], [1,2], [3,3], [2,1].

Constraints

  • start.length == 2 and target.length == 2.
  • Every position is a valid zero-based coordinate with 0 <= row < 10 and 0 <= column < 9.
  • start and target are distinct.
  • 0 <= obstacles.length <= 88.
  • Obstacle positions are unique, and neither start nor target is an obstacle.

More eBay interview questions

  • Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
  • Construct a Binary Tree from Preorder and InorderPHONE SCREEN · Seen Oct 2026
  • Maximum Size Subarray Sum Equals KPHONE SCREEN · Seen Sep 2026
  • Longest Palindromic SubstringPHONE SCREEN · Seen Aug 2026
  • K Smallest Elements from Sorted ArraysPHONE SCREEN · Seen Jul 2026
  • Single-Pass Search in a Rotated Sorted ArrayPHONE SCREEN · Seen Jul 2026
  • Extract Hashtags from a TweetONSITE INTERVIEW · Seen Nov 2026
  • Validate Ada Integer LiteralONSITE INTERVIEW · Seen Nov 2026
  • Count Distinct Pairs With Sum KONSITE INTERVIEW · Seen Nov 2026
  • Diameter of Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
  • Grid Infection with Recovery After D DaysOpenAI · PHONE SCREENOpenAI interview questions
  • Days Until Poisoned Plants StabilizeApple · PHONE SCREENApple interview questions
  • Retryable URL MazeRamp · PHONE SCREENRamp interview questions
  • Count Connected IslandsUber · PHONE SCREENUber interview questions
  • Number of IslandsSpaceX · PHONE SCREENSpaceX interview questions
All eBay interview questionsSee eBay hiring insights
Saved
class Solution {
    public boolean canHorseReach(int[] start, int[] target, int[][] obstacles) {
        // write your code here
    }
}
Checking account…