FastPrepAlphabet Board Path
Problems/Alphabet Board Path

Alphabet Board Path

Zillow logoZillow● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported at Zillow in a 2015 post by a candidate whose Zillow phone screens ran from September to November 2014 and whose onsite was pushed back to late January 2015. The Zillow part of the post lists this task next to a tree question with parent links and a binary search tree question. Letters sit row by row in a grid, three per row in the post's sample (A B C, then D E F, then G H I, and so on). Starting from A and moving only to a neighboring cell up, down, left or right, the candidate had to print each move and each letter of a word as it is reached; the post works through the word BEEF. The candidate found the task very easy but got it wrong by not thinking through enough cases, and advises settling the column before the row.

The post does not say which round asked it. The candidate noticed the mistake on a flight, so we place it in the onsite; that is our reading.

Our choices: the grid runs from A to Z with three letters per row, so the last row holds just Y and Z. Your function gets the word as a string of capital letters and returns every printed item in one string, one word per one-cell step, with single spaces between items. The move order is ours, built on the candidate's tip so that each word has one exact answer: column first, except when leaving the last row for the right-hand column, where you go up first. The length limit is ours as well.

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

The 26 capital letters are laid out on a board in alphabet order, three letters per row:

A B C
D E F
G H I
J K L
M N O
P Q R
S T U
V W X
Y Z

The last row holds just Y and Z, under A and B. The spot to the right of Z is empty, and you can never step onto it.

You start on A. Given a word, spell it letter by letter. Each step moves you one cell up, down, left or right. When you reach the next letter of the word, you print that letter. If the next letter is the one you are already on, you print it again without moving.

Return everything you print as one string. Write each one-cell step as the word up, down, left or right, write each letter as itself, and put a single space between items.

To get from one letter to the next, first move left or right until you are in the next letter's column, then move up or down until you reach it. There is one exception: if you are on the last row and the next letter is in the right-hand column (C, F, I, ..., X), a step right would land on the empty spot, so move up to the next letter's row first, then right.

This order never wastes a step, so every word has exactly one correct answer.

Function

alphabetBoardPath(word: String) → String

Examples

Example 1

word = "BEEF"return = "right B down E E right F"

From A, one step right reaches B, and one step down from there reaches E.

The next letter is E again, so it is printed with no step. One step right from E reaches F.

Example 2

word = "FIZZ"return = "right right down F down I left down down down down down down Z Z"

Reaching F from A takes two steps right, then one step down. I is one row below F.

From I, one step left puts you in the column of Z, then six steps down reach Z. Moving down first would have run into the empty spot at the bottom of the right-hand column. The second Z needs no step.

Example 3

word = "YOU"return = "down down down down down down down down Y up up up up right right O down down U"

Y is in the same column as A, eight rows lower, so it takes eight steps down.

O is in the right-hand column and you are on the last row, so the exception applies: four steps up reach M on the row of O, then two steps right reach O. U is two rows below O.

Constraints

  • 1 <= word.length <= 100
  • word consists of capital English letters A to Z.

More Zillow Onsite Interview questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • First Subarray with the Largest SumOA · ONSITE INTERVIEW · Seen Aug 2021
  • Count Duplicate CharactersONSITE INTERVIEW · Seen Oct 2020
  • Decision Tree Classifier from ScratchONSITE INTERVIEW · Seen Nov 2019
  • Find Median from Data StreamPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2018
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2016
  • Tic-Tac-Toe Winner on a Huge BoardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2016
  • Most Frequent Three-Page SequencesPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2016

Similar questions at other companies

  • BitFont Part 1 - Render a CharacterStripe · ONSITE INTERVIEWStripe interview questions
  • Cyclic Fuel Command SimulationWaymo · ONSITE INTERVIEWWaymo interview questions
  • Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
  • Collect Letters Along a Unique Grid PathApple · OAApple interview questions
  • Repair One Movement InstructionOpenAI · OAOpenAI interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • Count Straight-Line Word Occurrences in a GridVisa · OAVisa interview questions
  • Flip Rows and Columns, Count ZerosNutanix · OANutanix interview questions
  • Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public String alphabetBoardPath(String word) {
        // Write your code here.
    }
}
Checking account…