由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Google 面题
相关主题
这个check whether a binary tree is a BST 问题Google Front-end Software Engineer Phone Interview
一个老题binary tree找 lowest common ancestor 的code (请教Given a node of a tree, find all nodes on the same level
Find the node with given value in binary tree in in-orderbloomberg onsite题
这个Binary Tree的题来看看How to find the kth biggest number in a BST
谁有较好的iterative后序遍历binary tree的代码?A家,link all node in the same lev
求教一道经典面题的解法Lowest common ancestor of two nodes of Binary Tree
今天面试惨败,分享面经讨论Amazon的一道题:根节点到叶节点之间最小和,并打印路径
一道面试题生成树
相关话题的讨论汇总
话题: string话题: return话题: node话题: complete话题: sum
进入JobHunting版参与讨论
1 (共1页)
m*******m
发帖数: 82
1
Interview Questions:
1.Given a node in a binary tree find the next greatest value in the entire
node.
2.Given a string with only ')' and '(' find if the string is complete or
not. If the string is complete means that each open paranthesis should have
a corresponding closed one.
Eg: String s= "((()))()"- Complete String
String s1=")()()()())))(()()()((" - Incomplete String
r*****b
发帖数: 310
2
Do not understand the first question well. Any explanation?
Here is my answer to the second question:
http://basicalgos.blogspot.com/2012/03/19-testing-whether-strin
Please give out comments.

entire
have

【在 m*******m 的大作中提到】
: Interview Questions:
: 1.Given a node in a binary tree find the next greatest value in the entire
: node.
: 2.Given a string with only ')' and '(' find if the string is complete or
: not. If the string is complete means that each open paranthesis should have
: a corresponding closed one.
: Eg: String s= "((()))()"- Complete String
: String s1=")()()()())))(()()()((" - Incomplete String

P*******U
发帖数: 203
3
The first one is BST or just binary tree? What do you mean by the next
greatest value? Is it the second largest value?
If BST and next means second largest, then easy.
Node* p=givenNode;
if(p->rightChild==null)
return FindLargestInLeftSubtree();
while(p->rightChild->rightChild!=null)
p=p->rightChild;
return p;
If not BST, you have to traverse the tree?
The second one can be solved with a stack. Once seen a "(", push into
stack;
seen a ")", pop. If the stack is empty when operating pop, return false.
When processed all symbols in the string, if the stack is not empty,
return
false, else return true.
m*******m
发帖数: 82
4
The first question, I guess it is a binary search tree? And does each node
have a parent pointer?
for BST : get the node and find the inorder successor
if(n->right) : find minimum in n->right
else
find parent of n in loop, till n is parent->right :
(n = parent, find parent(n)
r*****b
发帖数: 310
5
As for the second question, a counter should be sufficient. The stack is
not needed.
http://basicalgos.blogspot.com/2012/03/19-testing-whether-strin

【在 P*******U 的大作中提到】
: The first one is BST or just binary tree? What do you mean by the next
: greatest value? Is it the second largest value?
: If BST and next means second largest, then easy.
: Node* p=givenNode;
: if(p->rightChild==null)
: return FindLargestInLeftSubtree();
: while(p->rightChild->rightChild!=null)
: p=p->rightChild;
: return p;
: If not BST, you have to traverse the tree?

m******6
发帖数: 82
6
1-没大看明白
2- stack
在 musicworm (云淡了风轻) 的大作中提到: 】
entire
~~~~~tree??
have
a****a
发帖数: 186
7
1.BST
2.one counter should be enough

【在 m******6 的大作中提到】
: 1-没大看明白
: 2- stack
: 在 musicworm (云淡了风轻) 的大作中提到: 】
: entire
: ~~~~~tree??
: have

m******6
发帖数: 82
8

2.one counter should be enough ~~good!

【在 a****a 的大作中提到】
: 1.BST
: 2.one counter should be enough

m*******m
发帖数: 82
9
another question:
what are the Google products?
y*****n
发帖数: 243
10
1就是找floor吧。上数据结构的时候讲过- -
m*****k
发帖数: 731
11
for Q2:
int sum=0;
for (char c in yourString)
{
if(c=='(')
{
sum++;
}
else
{
sum--;
}
if(sum<0)
{
return "invalid";
}
}
if(sum!=0)
{
return "invalid";
}
return "valid";
1 (共1页)
进入JobHunting版参与讨论
相关主题
生成树谁有较好的iterative后序遍历binary tree的代码?
G题,把binary tree里面的sibling节点连接起来求教一道经典面题的解法
在版上看到的G题今天面试惨败,分享面经
T第二轮面经一道面试题
这个check whether a binary tree is a BST 问题Google Front-end Software Engineer Phone Interview
一个老题binary tree找 lowest common ancestor 的code (请教Given a node of a tree, find all nodes on the same level
Find the node with given value in binary tree in in-orderbloomberg onsite题
这个Binary Tree的题来看看How to find the kth biggest number in a BST
相关话题的讨论汇总
话题: string话题: return话题: node话题: complete话题: sum