标签归档:leetcode

RSS feed of leetcode

[LeetCode]Word Ladder

题目描述:

Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:

Only one letter can be changed at a time

Each intermediate word must exist in the dictionary ...

继续阅读

[LeetCode]Binary Tree Paths

题目描述:

Given a binary tree, return all root-to-leaf paths.

For example, given the following binary tree:

   1
 /   \
2     3
 \
  5

All root-to-leaf paths are:

["1->2->5", "1->3"]

题目大意:

给定一棵二叉树,返回所有“根到叶子”的路径。

例如,给定下面的二叉树:

   1
 /   \
2     3
 \
  5

所有“根到叶子”路径为:

["1->2->5", "1->3"]

解题思路:

树的遍历 ...

继续阅读