由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请教一个Leetcode付费题
相关主题
上几个面经顺求Bless今天上一题
recovery BST 不考虑相同值的情况么?Link nodes at same level in a binary tree 怎么做?
Find number of subtrees with the same valueGoogle Front-end Software Engineer Phone Interview
这个Binary Tree的题来看看How to find the kth biggest number in a BST
求教balanced binary tree的准确定义BST 找重复节点数
请教find number of duplicates in a binary search treeAmazon 打印给定node距离最近的K个nodes
关于检查Binary tree是否balancedUni_value subtree problem
两个有点难度很有意思的题Amazon Interview: algorithm for 2*LOG(N) up bound for search
相关话题的讨论汇总
话题: subtree话题: given话题: leetcode话题: subtrees话题: uni
进入JobHunting版参与讨论
1 (共1页)
s*******r
发帖数: 9
1
250 Count Univalue Subtrees
Given a binary tree, count the number of uni-value subtrees.
A Uni-value subtree means all nodes of the subtree have the same value.
For example:
Given binary tree,
5
/ \
1 5
/ \ \
5 5 5
return 4.
195 / 197 test cases passed.
有一个case通不过
Input:
[5,5,5,5,5,null,5]
Output:
4
Expected:
6
实在没看出来有6个,是我题目理解不对?
l*****a
发帖数: 14598
2
for the three 5 in the right,
all 3 5 is one
top 2 5 is one
bottom 2 5 is one
the bottom 5 is one

【在 s*******r 的大作中提到】
: 250 Count Univalue Subtrees
: Given a binary tree, count the number of uni-value subtrees.
: A Uni-value subtree means all nodes of the subtree have the same value.
: For example:
: Given binary tree,
: 5
: / \
: 1 5
: / \ \
: 5 5 5

s*******r
发帖数: 9
3
for this case [5,5,5,5,5,null,5] the tree should be like
5
/
5 5
/
5 5 5
Sorry I still not get your answer.
My understanding is
the bottom three nodes contributes 3
the second left node subtree contribute 1
so the total is 4?

【在 l*****a 的大作中提到】
: for the three 5 in the right,
: all 3 5 is one
: top 2 5 is one
: bottom 2 5 is one
: the bottom 5 is one

l******s
发帖数: 3045
4
root and root.right are another 2.

【在 s*******r 的大作中提到】
: for this case [5,5,5,5,5,null,5] the tree should be like
: 5
: /
: 5 5
: /
: 5 5 5
: Sorry I still not get your answer.
: My understanding is
: the bottom three nodes contributes 3
: the second left node subtree contribute 1

j**********3
发帖数: 3211
5
我们都没钱付费,所以每做过
l******s
发帖数: 3045
6
顺便问一下lz付费后看到的公司面试的那些信息质量如何?比glassdoor 和
geeksforgeeks上列出来的那些怎样?
n*******s
发帖数: 17267
7
结果4是三个node 5外加一个node 1吧,后面的input跟binary tree 有个bird 关系

【在 s*******r 的大作中提到】
: 250 Count Univalue Subtrees
: Given a binary tree, count the number of uni-value subtrees.
: A Uni-value subtree means all nodes of the subtree have the same value.
: For example:
: Given binary tree,
: 5
: / \
: 1 5
: / \ \
: 5 5 5

n*******s
发帖数: 17267
8
另外,这种题有啥作头,不就是递归。。。吗,为啥要付费?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Amazon Interview: algorithm for 2*LOG(N) up bound for search求教balanced binary tree的准确定义
问个binary search tree的问题请教find number of duplicates in a binary search tree
上周Juniper onsite面经关于检查Binary tree是否balanced
问道150上的题:sum of path in binary tree两个有点难度很有意思的题
上几个面经顺求Bless今天上一题
recovery BST 不考虑相同值的情况么?Link nodes at same level in a binary tree 怎么做?
Find number of subtrees with the same valueGoogle Front-end Software Engineer Phone Interview
这个Binary Tree的题来看看How to find the kth biggest number in a BST
相关话题的讨论汇总
话题: subtree话题: given话题: leetcode话题: subtrees话题: uni