摘要:
题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.代码:/** * Definition for singly-linked ... 阅读全文
摘要:
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.代码:/** * Definition for a binary tree node. * stru... 阅读全文
摘要:
题目: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 onl... 阅读全文
摘要:
题目:Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 ... 阅读全文
摘要:
题目:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. ... 阅读全文
摘要:
题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码:/** * De... 阅读全文
摘要:
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码:/** * Def... 阅读全文
摘要:
题目:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution s... 阅读全文
摘要:
题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattene... 阅读全文
摘要:
题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / ... 阅读全文