PracHub
QuestionsLearningGuidesInterview Prep
|Home/Coding & Algorithms/eBay

Determine Reachability for a Chinese-Chess Horse with Blocked Legs

Last updated: Jul 22, 2026

Quick Overview

Determine whether a Chinese-chess horse can reach a target on a 10-by-9 board when obstacles block both destinations and the horse's leg squares. The exercise tests finite-state graph traversal, precise move generation, board boundaries, visited-state handling, and zero-move reachability.

  • hard
  • eBay
  • Coding & Algorithms
  • Software Engineer

Determine Reachability for a Chinese-Chess Horse with Blocked Legs

Company: eBay

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

# Determine Reachability for a Chinese-Chess Horse with Blocked Legs Implement a function that determines whether a Chinese-chess horse can reach a target square from a starting square on a standard 10-row by 9-column board. Some squares contain obstacles. An obstacle cannot be occupied, and it can also block the horse's “leg.” The horse may make any number of legal moves. ## Function Signature ```python def can_reach(start: list[int], target: list[int], blocked: list[list[int]]) -> bool: ``` ## Inputs - `start` is `[row, column]` for the initial square. - `target` is `[row, column]` for the destination square. - `blocked` contains distinct obstacle coordinates. - Rows are numbered `0` through `9`; columns are numbered `0` through `8`. - `start` and `target` are valid board coordinates and are not blocked. ## Movement Rules A horse move changes position by two squares along one axis and one square along the other axis. For a move with a two-row change, the orthogonally adjacent square one row toward the destination is the leg square. For a move with a two-column change, the orthogonally adjacent square one column toward the destination is the leg square. The move is legal only when the destination is on the board, the destination is not blocked, and the leg square is not blocked. ## Output Return `True` if the target is reachable by zero or more legal moves; otherwise return `False`. ## Constraints - `0 <= len(blocked) <= 88` - All coordinates in `blocked` are unique and valid. - The input collections must not be mutated. ## Examples ```text start = [0, 0] target = [2, 1] blocked = [] output = True ``` ```text start = [0, 0] target = [2, 1] blocked = [[1, 0], [0, 1]] output = False ``` In the second example, both possible first-move directions from the corner have blocked leg squares.

Quick Answer: Determine whether a Chinese-chess horse can reach a target on a 10-by-9 board when obstacles block both destinations and the horse's leg squares. The exercise tests finite-state graph traversal, precise move generation, board boundaries, visited-state handling, and zero-move reachability.

Related Interview Questions

  • Wildcard Dictionary Matching - eBay (medium)
  • Format Words into Fixed-Width Lines - eBay (medium)
  • Assign Ads to Browser Positions - eBay (medium)
  • Solve Dependency, Prefix, and Cache Problems - eBay (medium)
|Home/Coding & Algorithms/eBay

Determine Reachability for a Chinese-Chess Horse with Blocked Legs

eBay logo
eBay
Jul 9, 2026, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
1
0

Determine Reachability for a Chinese-Chess Horse with Blocked Legs

Implement a function that determines whether a Chinese-chess horse can reach a target square from a starting square on a standard 10-row by 9-column board. Some squares contain obstacles. An obstacle cannot be occupied, and it can also block the horse's “leg.” The horse may make any number of legal moves.

Function Signature

def can_reach(start: list[int], target: list[int], blocked: list[list[int]]) -> bool:

Inputs

  • start is [row, column] for the initial square.
  • target is [row, column] for the destination square.
  • blocked contains distinct obstacle coordinates.
  • Rows are numbered 0 through 9 ; columns are numbered 0 through 8 .
  • start and target are valid board coordinates and are not blocked.

Movement Rules

A horse move changes position by two squares along one axis and one square along the other axis. For a move with a two-row change, the orthogonally adjacent square one row toward the destination is the leg square. For a move with a two-column change, the orthogonally adjacent square one column toward the destination is the leg square. The move is legal only when the destination is on the board, the destination is not blocked, and the leg square is not blocked.

Output

Return True if the target is reachable by zero or more legal moves; otherwise return False.

Constraints

  • 0 <= len(blocked) <= 88
  • All coordinates in blocked are unique and valid.
  • The input collections must not be mutated.

Examples

start = [0, 0]
target = [2, 1]
blocked = []
output = True
start = [0, 0]
target = [2, 1]
blocked = [[1, 0], [0, 1]]
output = False

In the second example, both possible first-move directions from the corner have blocked leg squares.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More eBay•More Software Engineer•eBay Software Engineer•eBay Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.