码迷,mamicode.com
首页 >  
搜索关键字:given n integers    ( 24278个结果
LeetCode OJ - Minimum && Maximum Depth of Binary Tree
这两道题用递归的解法都很简单,只是稍有不同。下面是AC代码: 1 /** 2 * Given a binary tree, find its minimum depth. 3 * the minimum depth is the number of nodes along th...
分类:其他好文   时间:2014-05-10 08:47:32    阅读次数:271
LeetCode OJ - construct Binary Tree from Inorder and Postorder/Preorder Traversal
不断递归的实现!!!!下面是AC代码: 1 /** 2 * Given inorder and postorder traversal of a tree, construct the binary tree. 3 * @param inorder 4 * @param...
分类:其他好文   时间:2014-05-10 08:40:40    阅读次数:297
POJ3468 A Simple Problem with Integers ( 线段树)
题目:A Simple Problem with IntegersTime Limit:5000MSMemory Limit:131072KTotal Submissions:55817Accepted:16839Case Time Limit:2000MSDescriptionYou haveN....
分类:其他好文   时间:2014-05-09 17:04:14    阅读次数:339
LeetCode: Triangle 题解
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:其他好文   时间:2014-05-08 21:08:25    阅读次数:407
水题一枚
Description Given a code (not optimized), and necessary inputs, you have to find the output of the code for the inputs. The code is as follows: int a,...
分类:其他好文   时间:2014-05-07 09:56:16    阅读次数:310
Leetcode | Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:其他好文   时间:2014-05-07 09:36:09    阅读次数:300
LeetCode OJ - Validate Binary Search Tree
验证二叉树是否是查找树,可以通过查看它的中序遍历是否是升序的。下面是AC代码: 1 /** 2 * Given a binary tree, determine if it is a valid binary search tree (BST). 3 * solution : 4...
分类:其他好文   时间:2014-05-07 09:01:45    阅读次数:250
LeetCode OJ - Balanced Binary Tree
判断树是否是平衡的,这道题中的平衡的概念是指任意节点的两个子树的高度相差不超过1,我用递归的方法把所有的节点的高度都计算了下,并且在计算的过程记录每个节点左右两颗子树的高度差,最后通过遍历这个高度差就可以知道是否是平衡的。下面是AC代码: 1 /** 2 * Given a binary...
分类:其他好文   时间:2014-05-05 09:54:44    阅读次数:378
LeetCode OJ - Symmetric Tree && Same Tree
这两道题,大同小异。 我都是用BFS,在遍历的过程,判断结构是否相同/对称,值是否相同。下面是AC代码: 1 /** 2 * Given a binary tree, check whether it is a mirror of itself (ie, symmetric aroun...
分类:其他好文   时间:2014-05-05 09:48:26    阅读次数:401
LeetCode OJ - Binary Tree Level Order Traversal 1 && 2
BFS以及它的扩展,我发现栈是个很好用的数据结构,特别是对于顺序需要颠倒的时候!!!这里有个重要的信息:可以用null来标识一个level的结束!!!下面是AC代码: 1 /** 2 * Given a binary tree, return the bottom-up level ord...
分类:其他好文   时间:2014-05-05 09:46:06    阅读次数:402
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!