码迷,mamicode.com
首页 >  
搜索关键字:minimum sum lcm    ( 24851个结果
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: Minimum Depth of Binary Tree
这道题因为不仔细的缘故两次过,与Maximum Depth of Binary Tree问题类似,区别在于这个问题中,如果一个节点左子树为空、右子树有值,则该节点的深度应取决于右子树,而不能直接取min{左,右} 1 /** 2 * Definition for binary tree 3 * .....
分类:其他好文   时间:2014-05-10 01:40:13    阅读次数:293
Edit Distance
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
分类:其他好文   时间:2014-05-10 01:09:28    阅读次数:325
Leetcode | Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have t...
分类:其他好文   时间:2014-05-09 19:09:35    阅读次数:318
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
shell脚本练习题(更新中...)
练习题(这里贴的是自己写的代码, 网上给的题目代码我会附加在最下面)1.编写shell脚本,计算1-100的和; 1 #!/bin/bash 2 #caculate the sum of numbers from 1 to 100 3 4 sum=0 5 for i in `seq 1 100`;....
分类:其他好文   时间:2014-05-07 19:34:54    阅读次数:305
[leetcode] Path sum路径之和
要求给定树,与路径和,判断是否存在从跟到叶子之和为给定值的路径。比如下图中,给定路径之和为22,存在路径,因此返回true;否则返回false. 5 / \ 4 8 / / \ 11...
分类:其他好文   时间:2014-05-07 10:15:46    阅读次数:270
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
68
$\bf命题1:$设正项级数$\sum\limits_{n = 1}^\infty {{a_n}} $发散,且${s_n} = \sum\limits_{k = 1}^n {{a_k}} $,试讨论级数$\sum\limits_{n = 1}^\infty {\frac{{{a_n}}}{{{s_n...
分类:其他好文   时间:2014-05-04 19:03:33    阅读次数:360
求数组中和为给定值的任意两个数
题目: 输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字。要求时间复杂度是O(n)。如果有多对数字的和等于输入的数字,输出任意一对即可。 例如输入数组1、2、4、7、11、15和数字15。由于4+11=15,因此输出4和11。 思路: 最直接的做法是暴力法,两个for循环,时间复杂度为O(n*n),但是这样没有充分利用升序数组这一前提。我们假设数组为A,长度为len,给定的和为sum,最好的方法是先用数组的第一个数A[lo...
分类:其他好文   时间:2014-05-04 17:56:57    阅读次数:596
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!