2014年(53)
发布时间:2014-12-06 16:46:38
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.比较奇葩的设定,要是没有左子树,那么就要算右子树的最小高度。int minDepth(TreeNode *root) { &n.........【阅读全文】
发布时间:2014-12-06 15:42:18
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.很像那个镜像的树,思想完全一样。bool isSameTree(TreeNode *p, TreeNode *q) {  .........【阅读全文】
发布时间:2014-12-06 15:36:05
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Show TagsHave you met t.........【阅读全文】
发布时间:2014-12-06 15:30:01
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 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3判断一棵树是不是镜像。关于树,直接的.........【阅读全文】
发布时间:2014-10-07 15:30:17
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.我试着用了最简单的匹配,居然过了,以后再用KMP之类的好好研究一下。char *strStr(char *haystack, char *needle) {  .........【阅读全文】