02 2016 档案
摘要:把二元查找树转变成排序的双向链表题目:输入一棵二元查找树,将该转换成个排 序的双向链表。要求不能创建任何新的结点,只调整指针向。 10 / \ 6 14 / \ / \ 4 8 12 8转换成双向链表4=6=8=10=12=14=16 利用中序遍历来解决比较简单,这里我主要提供一种非递归版本来解决这
阅读全文
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Subscribe to see which companies asked this question
阅读全文
摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4
阅读全文
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only
阅读全文
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F
阅读全文
摘要:最近在开发一款类似消消乐的三消游戏,在碰到实现斜方向下落的时候卡住了很长时间。好几天没有思路,原本的思路是一次性预判多个宝石的一连串运动路径,运用缓动运动队列来实现宝石运动路径,例如 下落->滑落->下落。用这种方式虽然会提高性能,但发现总是无法预判所有宝石运动路径,可能性太多了,比如某一个宝石的下
阅读全文