2013年11月15日

Same Tree

摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * ... 阅读全文

posted @ 2013-11-15 15:00 Step-BY-Step 阅读(134) 评论(0) 推荐(0) 编辑

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 keysless thanthe node's key.The right subtree of a node contains only nodes with keysgreater thanthe node's key.Both the left and ri 阅读全文

posted @ 2013-11-15 14:10 Step-BY-Step 阅读(136) 评论(0) 推荐(0) 编辑

Binary Tree Inorder Traversal

摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文

posted @ 2013-11-15 13:16 Step-BY-Step 阅读(164) 评论(0) 推荐(0) 编辑

导航