leetCode
芮小谭
正面 积极
展开
-
[leetCode] Unique Binary Search Trees
在数据结构中,排序是处理数据的重要手段之一,而排序分为内部排序与外部排序。原创 2018-08-21 09:11:02 · 117 阅读 · 0 评论 -
[leetCode] Binary Tree Inorder Traversal
题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivi...原创 2018-08-21 09:27:57 · 151 阅读 · 0 评论 -
[LeetCode] Validate Binary Search Tree 验证二叉搜索树
题目: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 nodes with keys less than the node's key....原创 2018-08-21 09:31:06 · 155 阅读 · 0 评论 -
[LeetCode] Recover Binary Search Tree 复原二叉搜索树
题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you dev...原创 2018-08-21 09:33:41 · 152 阅读 · 0 评论 -
[LeetCode] Same Tree 判断两颗树是否相等
题目:给定两颗二叉树,写一个函数判断这两棵树是否相等。如果两棵树的结构和各节点中保存的值是相等的,则认为这两棵树相等。思路:采用先序遍历的方法,从上到下递归考察各节点。 在任意一对节点的比较中,如果左右枝是否为空的属性和节点中的val值不相等,则认为两棵树不是同一棵树,否则继续考察。如果遍历结束后仍然不能证明这两棵树不是同一棵树,则这两棵树就是相等的 实现代码如下:/...原创 2018-08-21 09:36:17 · 484 阅读 · 0 评论