Amazon Phone 2nd

今天Amazon2面,customer service tech team。

白人GG。上来什么直接让写代码,什么都没问。题目是求binary tree的高度。写了一个最简单的递归算法,然后让求复杂度,结果悲剧的说成了指数。

然后是test case:null, 1 node, full tree, left > right, right > left, list tree

如果是一个如果书中间有cycle怎么办?回答是hashtable

如果不让用global定义怎么办?回答是加一个参数 treeheight(node, hashtable)

如果不让改变函数接口怎么办?开始没想出来后来说写helper class

treeheight(node) {

treeHeightHelper(node, hashtable)

}

然后45分钟就过去了,不知道能不能还有onsite了,BLESS ME

 

Related Posts

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>