FastPrepLongest Path of Exact Jumps in a Grid
Problems/Longest Path of Exact Jumps in a Grid

Longest Path of Exact Jumps in a Grid

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem asks for the longest chain of exact-length jumps through a small grid without reusing a cell. A post from April 2022 about an Adobe MTS 1 interview (rejected) gives it as the third question of its first round. It came after a question on storing a tree for quick child lookups and a first-unique-character question. The author spells out the rules: a cell's number is the exact jump length, moves go in the four straight directions, and no cell may be used twice. The post also shows one 3 x 3 grid with its answer and a path that starts at the top-left corner.

Our choices: the path starts at the top-left cell, as in the post's sample path. That is a reading, since the rules do not name a start. Grids have 1 to 5 rows and columns with values from 0 to 9. The examples are new, and we did not use the post's grid. A cell holding 0 allows no jump, so it ends a path.

Our version is about 85% the same as the reported question.

You are given a grid of m rows and n columns holding non-negative integers. You start in the top-left cell (0, 0).

From a cell holding the value v, one jump moves exactly v cells up, down, left or right. A jump must land inside the grid on a cell that has not been visited yet (the start cell counts as visited). A cell holding 0 allows no jump, so a path that reaches it ends there.

Return the largest number of jumps any such path can make.

Function

longestJumpPath(grid: int[][]) → int

Examples

Example 1

grid = [[1,2,1],[0,1,1],[2,0,1]]return = 2
grid
012012110112201

One longest path: (0,0) → (0,1) → (2,1). From (0,0) the value 1 allows (0,1) or (1,0); (1,0) holds 0 and ends the path at once. From (0,1) the value 2 allows only (2,1), which holds 0. That is 2 jumps, and no path does better.

Example 2

grid = [[0,1],[1,1]]return = 0
grid
01001111

The start cell holds 0, so no jump is possible: the answer is 0.

Example 3

grid = [[1,1],[1,1]]return = 3
grid
01011111

Every cell holds 1, so each jump moves to a side neighbour. (0,0) → (0,1) → (1,1) → (1,0) visits all four cells: 3 jumps.

Constraints

  • 1 <= m, n <= 5, where m is the number of rows and n the number of columns
  • every row of grid has n cells
  • 0 <= grid[r][c] <= 9

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Word SearchCognitiv · PHONE SCREEN
  • Word SearchWhatNot · PHONE SCREEN
  • Adjacent-Key Lock PatternsC3.ai · PHONE SCREEN
  • Word Search IIApple · PHONE SCREEN
  • Word SearchAmazon · ONSITE INTERVIEW
  • Word SearchMicrosoft · ONSITE INTERVIEW
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEW
  • Trace a Word Through a Letter GridExpedia · ONSITE INTERVIEW
  • Rat in a Maze: All Simple PathsPeopleStrong · OA
See Adobe hiring insights
Saved
class Solution {
    public int longestJumpPath(int[][] grid) {
        // Write your code here.
    }
}
Checking account…