0
点赞
收藏
分享

微信扫一扫

leetcode-127-Word Ladder

简单聊育儿 2023-08-23 阅读 32


A good problem for me to analysis the time complexity. At first I want to create a graph for each word, I mean check each word is a available for the other. However, when I look up the solution I think the time complexity is O(n^2) to create the graph. Then I use the solution which they provide: for each position, try character from ‘a’ to ‘z’ literately, then see if current string is in the dictionary or not. So that the time complexity is O(n * 26^i)

Also, need to mention that we should use a map to know previous change position, so that it will go back.

Error:
N/A


举报

相关推荐

0 条评论