码迷,mamicode.com
首页 >  
搜索关键字:pascals triangle pas    ( 2128个结果
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-12-03 21:11:39    阅读次数:186
Pascal's Triangle II
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(...
分类:其他好文   时间:2014-12-03 21:10:42    阅读次数:188
leetcode Pascal's Triangle II
和Pascal's Triangle类似,这里是不需要记录所有的,而是给定一个行号,返回那一行的数据就可以了。例如:For example, givenk= 3,Return[1,3,3,1].所以给0的时候返回[1].题目要求O(k)空间,也就是除了要返回的空间外,其他是常数空间。那就用一个tmp...
分类:其他好文   时间:2014-12-02 13:26:48    阅读次数:185
leetcode Triangle
给定一个三角数组,找从上到下的最小和,例如:For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is11...
分类:其他好文   时间:2014-12-02 13:22:08    阅读次数:184
[LeetCode] Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 迭代 非递归版本 public class Solut...
分类:其他好文   时间:2014-12-01 22:35:09    阅读次数:204
[LeetCode]Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? public class...
分类:其他好文   时间:2014-12-01 22:30:11    阅读次数:201
[4Clojure]解题记录-#79
Triangle Minimal PathDifficulty:HardTopics:graph-theoryWrite a function which calculates the sum of the minimal path through a triangle. The triangle ...
分类:其他好文   时间:2014-12-01 22:08:35    阅读次数:197
HNU 13101 The Triangle Division of the Convex Polygon 组合数的因式分解求法
题意: 求第n-2个Catalan数 模上 m。思路: Catalan数公式: Catalan[n] = C(n, 2n)/(n+1) = (2n)!/[(n+1)!n!] 因为m是在输入中给的,所以我们不能用求阶乘和其逆元的方法来求。因为当m不是素数的时候,可能不存在逆元。 这里,我们把阶...
分类:其他好文   时间:2014-12-01 12:49:13    阅读次数:202
HOJ 13101 The Triangle Division of the Convex Polygon(数论求卡特兰数(模不为素数))
TheTriangleDivisionoftheConvexPolygon题意:求 n 凸多边形可以有多少种方法分解成不相交的三角形,最后值模 m。思路:卡特兰数的例子,只是模 m 让人头疼,因为 m 不一定是素数,所以不一定存在逆元。 解法:式子为f(n) = ( C( 2*(n-2), (...
分类:其他好文   时间:2014-12-01 12:42:11    阅读次数:186
leetcode Pascal's Triangle
给定行号,输出如下所示Pascal Triangle(杨辉三角)For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路,想到右上一个构建下一个,构成过程就是上一个的相邻...
分类:其他好文   时间:2014-11-30 23:09:06    阅读次数:232
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!