LeetCode icon indicating copy to clipboard operation
LeetCode copied to clipboard

getDepthRec

Open mousepotato opened this issue 10 years ago • 6 comments

if (root == null) {
  return -1;
}

应该是 return 0;

mousepotato avatar Oct 09 '14 17:10 mousepotato

你说的是哪一道题目?

这里应该是返回-1的。 九章算法有发过对数的各种定义的解析 ,你可以看一下。

Depth定义的是从根到最远的叶子节点的边的条数。 如果是只有根节点,应该是0.

如果是null 就应该是-1.

On Oct 9, 2014, at 10:08 AM, Shuangjiang Li [email protected] wrote:

if (root == null) { return -1; } 应该是 return 0;

— Reply to this email directly or view it on GitHub.

yuzhangcmu avatar Oct 09 '14 18:10 yuzhangcmu

还有一个问题是 其实很多公司面试官对这个定义也不是特别清楚。 所以 在面试时 先问清楚他想要什么样的答案就行了。

On Oct 9, 2014, at 10:08 AM, Shuangjiang Li [email protected] wrote:

if (root == null) { return -1; } 应该是 return 0;

— Reply to this email directly or view it on GitHub.

yuzhangcmu avatar Oct 09 '14 18:10 yuzhangcmu

谢谢解释。觉得你是对的!

mousepotato avatar Oct 10 '14 19:10 mousepotato

另外 你的名字实在是太霸气了!

On Fri, Oct 10, 2014 at 12:28 PM, Shuangjiang Li [email protected] wrote:

谢谢解释。觉得你是对的!

— Reply to this email directly or view it on GitHub https://github.com/yuzhangcmu/LeetCode_algorithm/issues/1#issuecomment-58704724 .

yuzhangcmu avatar Oct 10 '14 19:10 yuzhangcmu

哈哈,九章群里我也在。。

mousepotato avatar Oct 15 '14 00:10 mousepotato

给您跪下咯。 On Oct 14, 2014, at 5:10 PM, Shuangjiang Li [email protected] wrote:

哈哈,九章群里我也在。。

— Reply to this email directly or view it on GitHub.

yuzhangcmu avatar Oct 15 '14 01:10 yuzhangcmu