FastPrepWord Path Moving Only Right or Down
Problems/Word Path Moving Only Right or Down

Word Path Moving Only Right or Down

Indeed logoIndeed● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The guaranteed-present right/down coordinate-path task and original cases match the source at about 95%; the source accepts any path, while this exercise chooses the lexicographically smallest path for exact grading. Indexing and bounds are defined here.

Find a path spelling word in a rectangular character grid. The word may start at any cell. Each next letter must be in the immediately adjacent cell to the right or directly below the current cell. The word is guaranteed to be present.

Return one coordinate [row,column] for each letter, in word order. For this exercise, assume zero-based coordinates and represent the grid as an array of equal-length row strings.

Several valid paths may exist. For this exercise, assume the lexicographically smallest complete coordinate path must be returned. Compare paths at the first differing coordinate, comparing row before column. This chooses starting cells in row-major order and prefers a feasible right continuation over a feasible down continuation.

For this exercise, assume all grid and word characters are lowercase English letters and both the grid and word are nonempty.

Function

gridPath(grid: String[], word: String) → int[][]

Examples

Example 1

grid = ["cctnax","ccatnt","acnntt","tniipp","aoooaa","saaaoo","kaioki"]word = "catnip"return = [[1,1],[1,2],[1,3],[2,3],[3,3],[3,4]]
grid
0123450cctnax1ccatnt2acnntt3tniipp4aoooaa5saaaoo6kaioki
→
return
01011112213323433534

The path spells catnip using only adjacent right and down moves.

Example 2

grid = ["cctnax","ccatnt","acnntt","tniipp","aoooaa","saaaoo","kaioki"]word = "cccc"return = [[0,0],[0,1],[1,1],[2,1]]
grid
0123450cctnax1ccatnt2acnntt3tniipp4aoooaa5saaaoo6kaioki
→
return
01000101211321

Two paths spell the word. The lexicographically smallest path goes right from [0,0] before going down.

Constraints

  • For this exercise, assume grid height and width are each from 1 through 30.
  • All row strings have the same length.
  • 1 <= word.length <= height + width - 1.
  • At least one right/down path spells the word.

More Indeed Phone Screen questions

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
  • Rotting Orange PropagationPHONE SCREEN · Seen May 2025
  • Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
  • First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
  • Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
  • Resource Transition GraphPHONE SCREEN · Seen Jul 2022
  • Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022

Similar questions at other companies

  • Enumerate Right-and-Down Matrix PathsBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Word Path Moving Only Right or DownWayfair · PHONE SCREENWayfair interview questions
  • Enumerate Right-and-Down Matrix PathsOracle · ONSITE INTERVIEWOracle interview questions
  • Find a Word Path Moving Right or DownIntuit · OAIntuit interview questions
  • Count Eight-Neighbor Unlock PatternsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Empty ShelfSquarepoint Capital · OASquarepoint Capital interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Unique Grid PathsMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
  • Count Starts Reaching a Grid MaximumDuolingo · PHONE SCREENDuolingo interview questions
  • Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions

Indeed interview experiences

  • Indeed Experienced SWE Karat Screens and OAs: 6 Experiences
  • Indeed SWE Intern Karat Screens and OA: 3 Experiences
  • Indeed New Grad SWE Online Assessments: 3 Experiences
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public int[][] gridPath(String[] grid, String word) {
        // Write your code here.
        return new int[0][0];
    }
}
Checking account…