FastPrepWord Ladder
Problems/Word Ladder

Word Ladder

Google logoGoogle● HardINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the standard shortest Word Ladder task, but leaves out the input limits and a few edge rules. Our version is about 94% the same as the reported question.

Given two distinct lowercase words beginWord and endWord, and an array wordList, return the number of words in the shortest transformation sequence from beginWord to endWord.

Each transformation changes exactly one letter, and every transformed word after beginWord must appear in wordList. Return 0 when no valid sequence exists.

Function

ladderLength(beginWord: String, endWord: String, wordList: List<String>) → int

Examples

Example 1

beginWord = "hit"endWord = "cog"wordList = ["hot","dot","dog","lot","log","cog"]return = 5

One shortest sequence is hit → hot → dot → dog → cog, which contains 5 words.

Example 2

beginWord = "hit"endWord = "cog"wordList = ["hot","dot","dog","lot","log"]return = 0

The destination cog is unavailable, so no valid sequence can reach it.

Example 3

beginWord = "lost"endWord = "cost"wordList = ["most","fist","lost","cost","fish"]return = 2

Changing the first letter transforms lost directly into cost.

Constraints

  • 1 <= beginWord.length == endWord.length <= 10.
  • beginWord and endWord are distinct lowercase English words.
  • 1 <= wordList.length <= 5000.
  • Every entry in wordList is a unique lowercase word with the same length as beginWord.
  • beginWord does not need to appear in wordList.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Find Duplicate Files in a FilesystemHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Word LadderGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Word LadderMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Word Ladder IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Shortest Word Transformation SequenceReddit · PHONE SCREENReddit interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Find Minimum City HopsAmazon · OA
  • Shortest Path from Encoded Graph EdgesBitGo · OABitGo interview questions
  • Minimum Bus Routes to a DestinationPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Jump Game IVZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int ladderLength(String beginWord, String endWord, List<String> wordList) {
        // Write your code here.
    }
}
Checking account…