LeetCode
LeetCode copied to clipboard
getDepthRec
if (root == null) {
return -1;
}
应该是 return 0;
你说的是哪一道题目?
这里应该是返回-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.
还有一个问题是 其实很多公司面试官对这个定义也不是特别清楚。 所以 在面试时 先问清楚他想要什么样的答案就行了。
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.
谢谢解释。觉得你是对的!
另外 你的名字实在是太霸气了!
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 .
哈哈,九章群里我也在。。
给您跪下咯。 On Oct 14, 2014, at 5:10 PM, Shuangjiang Li [email protected] wrote:
哈哈,九章群里我也在。。
— Reply to this email directly or view it on GitHub.