这两道题用递归的解法都很简单,只是稍有不同。下面是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
这道题因为不仔细的缘故两次过,与Maximum Depth of Binary
Tree问题类似,区别在于这个问题中,如果一个节点左子树为空、右子树有值,则该节点的深度应取决于右子树,而不能直接取min{左,右} 1 /** 2 *
Definition for binary tree 3 * .....
分类:
其他好文 时间:
2014-05-10 01:40:13
阅读次数:
293
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
DescriptionThe inversion number of a given
number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i
aj.For a given sequence of ....
分类:
其他好文 时间:
2014-05-05 11:42:13
阅读次数:
276
Minimum Inversion Number Time Limit:1000MS Memory
Limit:32768KB 64bit IO Format:%I64d & %I64u Description The inversion number
of a given number seque...
分类:
其他好文 时间:
2014-05-04 12:27:07
阅读次数:
349
一些基本函数的R-L分数阶导数:c. 幂函数
$t^{\mu}$$$_{0}^{RL}D_{t}^{\nu}t^{\mu}=\frac{\Gamma(1+\mu)}{1+\mu-\nu}t^{\mu-\nu}$$首先我们来计算
$t^{\mu}$的$\alpha$分数阶积分\begin{eqnarr...
分类:
其他好文 时间:
2014-05-04 11:52:09
阅读次数:
392
这道题,采用动态规划算法。from top to
down,把到每个节点的最小路径和都求出来。下面是AC代码: 1 /** 2 * Given a triangle, find the minimum path
sum from top to bottom. 3 * Each ...
分类:
其他好文 时间:
2014-05-02 12:19:23
阅读次数:
382
许多次通过,主要是没有考虑到这种情况:“A C ”结尾有多重空格的情况。 1 public class
Solution { 2 public int lengthOfLastWord(String s) { 3 int j, k; 4 if(s == nu...
分类:
其他好文 时间:
2014-05-02 08:21:00
阅读次数:
300
Given an array of integers, find two numbers
such that they add up to a specific target number.The function twoSum should
return indices of the two nu...
分类:
其他好文 时间:
2014-05-01 08:35:40
阅读次数:
443