Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Question Description

Given a 2D keyboard represented by a m × n character matrix, a maximum jump distance, and a target word, determine if you can type the word by moving between characters without exceeding this distance. The distance here is calculated as the Manhattan distance: ∣x1−x2∣+∣y1−y2∣|x1 - x2| + |y1 - y2|.

Constraints:

  • Jump distance ≥ 0
  • The word can have up to 1000 characters.
Test Cases
Input
Output
Expected