由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - [Google] Arangement of blocks
相关主题
一道动态规划题问个binary tree node path的概念问题
打印从根到叶子节点所有路径的问题英语理解力太烂: 题目看不懂
请教一个cracking coding interview书上的问题问两道facebook面试题
Career cup 4.9 path sum的答案肯定错了问一个graph题
借人气问一道Samsung的题Leetcode bst max path-----is this solution correct?
垒墙面试题求帮助Cracking上一道题求教
Amazon Interview QuestionCode a non blocking thread safe queue
二叉树如何判断一个节点是不是在另外两个节点的path上。。。。好像是个老题了。。求解?path sum II OJ 超时
相关话题的讨论汇总
话题: blocks话题: path话题: left话题: right话题: most
进入JobHunting版参与讨论
1 (共1页)
s*********l
发帖数: 103
1
http://discuss.techinterview.org/default.asp?interview.11.79942
You are given N blocks of height 1…N. In how many ways can you arrange
these blocks in a row such that when viewed from left you see only L blocks
(rest are hidden by taller blocks) and when seen from right you see only R
blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3}
while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.
g*********s
发帖数: 1782
2
brute-force?

blocks
R
3}

【在 s*********l 的大作中提到】
: http://discuss.techinterview.org/default.asp?interview.11.79942
: You are given N blocks of height 1…N. In how many ways can you arrange
: these blocks in a row such that when viewed from left you see only L blocks
: (rest are hidden by taller blocks) and when seen from right you see only R
: blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3}
: while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.

Z*****Z
发帖数: 723
3
Term:
13766
Web:
http://mitbbs.com/article1/JobHunting/31588989_3_0.html

blocks
}

【在 s*********l 的大作中提到】
: http://discuss.techinterview.org/default.asp?interview.11.79942
: You are given N blocks of height 1…N. In how many ways can you arrange
: these blocks in a row such that when viewed from left you see only L blocks
: (rest are hidden by taller blocks) and when seen from right you see only R
: blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3}
: while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.

s*********l
发帖数: 103
4
我的基本想法是构造满足条件的binary max heap,然后按中序输出,有点cartesian
tree的意思.

blocks
}

【在 s*********l 的大作中提到】
: http://discuss.techinterview.org/default.asp?interview.11.79942
: You are given N blocks of height 1…N. In how many ways can you arrange
: these blocks in a row such that when viewed from left you see only L blocks
: (rest are hidden by taller blocks) and when seen from right you see only R
: blocks? Example given N=3, L=2, R=1 there is only one arrangement {2, 1, 3}
: while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.

g*********s
发帖数: 1782
5
sorry, what's the connection to max heap?

【在 s*********l 的大作中提到】
: 我的基本想法是构造满足条件的binary max heap,然后按中序输出,有点cartesian
: tree的意思.
:
: blocks
: }

s*********l
发帖数: 103
6
seems the number of nodes on the left-most path is L
and the number of nodes on the right-most path is R
Examples:
(1) given N=3, L=2, R=1 there is only one arrangement {2, 1, 3}
{2,1,3} corresponds to the cartesian tree
3
/
2
\
1
Left-most path: 3->2
Right-most path: 3
(2) while for N=3, L=2, R=2 there are two ways {1, 3, 2} and {2, 3, 1}.
{1,3,2} corresponds to the cartesian tree
3
/ \
1 2
Left-most path: 3->1
Right-most path: 3->2
{2,3,1} corresponds to the cartesian tree
3
/ \
2 1
Left-most path: 3->2
Right-most path: 3->1

【在 g*********s 的大作中提到】
: sorry, what's the connection to max heap?
1 (共1页)
进入JobHunting版参与讨论
相关主题
path sum II OJ 超时借人气问一道Samsung的题
Graph problem垒墙面试题求帮助
求教两道FLAG题Amazon Interview Question
Google电面面经二叉树如何判断一个节点是不是在另外两个节点的path上。。。。好像是个老题了。。求解?
一道动态规划题问个binary tree node path的概念问题
打印从根到叶子节点所有路径的问题英语理解力太烂: 题目看不懂
请教一个cracking coding interview书上的问题问两道facebook面试题
Career cup 4.9 path sum的答案肯定错了问一个graph题
相关话题的讨论汇总
话题: blocks话题: path话题: left话题: right话题: most