Z34

Word Ladder Shortest Transformation

Staff / Principal Engineer
Target Time: 40 - 50 Minutes
Type: NUMERIC

Problem Statement & Objective

A transformation sequence from word beginWord to word endWord using a dictionary wordList. Return the number of words in the shortest transformation sequence.

Function Signature (Python)

word_ladder_shortest_transformation(start: str, target: str, words: list[str]) -> int

Input & Output Contract

Output Rule:En kısa dönüşüm zincirindeki kelime sayısı. Yoksa 0.

System Constraints

1 <= baslangic.length <= 10
hedef.length == baslangic.length
1 <= kelimeler.length <= 5000
Tüm kelimeler küçük harf içerir ve aynı uzunluktadır

Example Execution Walkthrough

baslangic = 'hit', hedef = 'cog', kelimeler = ['hot','dot','dog','lot','log','cog']
'hit' -> 'hot' -> 'dot' -> 'dog' -> 'cog' (5 kelime)
cevap: 5

Example Test Scenarios (3)

Example 1
Input:["hit","cog",["hot","dot","dog","lot","log","cog"]]
Expected Output:5
Example 2: Hedef Sözlükte Yok
Input:["hit","cog",["hot","dot","dog","lot","log"]]
Expected Output:0
Example 3: Tek Harfli
Input:["a","c",["a","b","c"]]
Expected Output:2
Loading Python Editor...
Input Parameters
[
  "hit",
  "cog",
  [
    "hot",
    "dot",
    "dog",
    "lot",
    "log",
    "cog"
  ]
]
Expected Output
5