摘要:
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. N 阅读全文
摘要:
Invert a binary tree. 思路1 递归: 把左子树和右子树进行交换。交换完之后,再去递归翻转左子树和右子树 思路2 遍历 换父节点的时候,把子节点存下来,然后换完父节点了,就去换子点的。 阅读全文
摘要:
Given a binary tree, determine if it is height balanced. For this problem, a height balanced binary tree is defined as: a binary tree in which the dep 阅读全文
摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height balanced binary tree is d 阅读全文
摘要:
Given a binary tree, return the bottom up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 思路: 阅读全文
摘要:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). 思路1: 递归 如果两个树p,q是对称的,那么p的左子树和q的右子树是对称的,p的右子树和左子树是对称的, 思 阅读全文
摘要:
Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
摘要:
设计一个找到数据流中第K大元素的类(class)。注意是排序后的第K大元素,不是第K个不同的元素。 你的 KthLargest 类需要一个同时接收整数 k 和整数数组nums 的构造器,它包含数据流中的初始元素。每次调用 KthLargest.add,返回当前数据流中第K大的元素。 示例: 思路1 阅读全文