等等我,主人!# Joke - 肚皮舞运动
g*j
1 楼
这个经典题目
Given two words (start and end), and a dictionary, find the length of
shortest transformation sequence from start to end, such that:
Only one letter can be changed at a time
Each intermediate word must exist in the dictionary
我理解的就是构建一个图,如果两个单词之间只有一个字母不一样,就有路径,然后找
从start到end的最短路径,是这样的么?
但是,这个说起来容易写起来难啊,面试的时候难道还要写一个最短路径的算法么?
另外,这个图如何构建呢?如何快速的判断两个单词只有一个字母不一样呢?
以前以为很容易,动手开始写了才知道好难,至少不像平时面试的那种20行就可以搞定
的题目
请问是我理解错了,还是有别的更加优化的算法?
谢谢了!
Given two words (start and end), and a dictionary, find the length of
shortest transformation sequence from start to end, such that:
Only one letter can be changed at a time
Each intermediate word must exist in the dictionary
我理解的就是构建一个图,如果两个单词之间只有一个字母不一样,就有路径,然后找
从start到end的最短路径,是这样的么?
但是,这个说起来容易写起来难啊,面试的时候难道还要写一个最短路径的算法么?
另外,这个图如何构建呢?如何快速的判断两个单词只有一个字母不一样呢?
以前以为很容易,动手开始写了才知道好难,至少不像平时面试的那种20行就可以搞定
的题目
请问是我理解错了,还是有别的更加优化的算法?
谢谢了!