上一页 1 ··· 4 5 6 7 8

2014年1月13日

LeetCode: Generate Parentheses

摘要: Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"最开始想的是,先产生n-1的情况,然后在n-1中的每个string的前面,后面加上()以及用()扩住整个string。 阅读全文

posted @ 2014-01-13 10:10 longhorn 阅读(186) 评论(0) 推荐(0) 编辑

2013年11月30日

LeetCode: combinations

摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.解决这个问题有两种思路:1. 从n个找出k个的所有组合,可以是从n-1个中找到k个的所有组合加上n-1个中找到k-1个的所有组合再加上nf(n,k) = {f(n-1, k), [f(n-1, k-1), k] }2. 从n个中找出k个的所有组合,可以是从n个中找到以n结尾的k个的组合,加上从n-1个中找到以n-1结尾的k个的组合,加上。。。。f(n,k) = { f(n-1, k), f(n-2, k), ...., f(k, 阅读全文

posted @ 2013-11-30 07:36 longhorn 阅读(177) 评论(0) 推荐(0) 编辑

2013年11月29日

LeetCode: Set Matrix Zeros

摘要: O(1)的算法:常数空间的话,第一可以考虑是不是固定数量的几个变量能搞定;否则可以考虑是不是问题本身已经提供了足够的空间。这道题属于后者,就是利用矩阵的第一行和第一列来作为辅助空间使用。不用开辟新的存储空间。---恢复内容结束--- 阅读全文

posted @ 2013-11-29 06:21 longhorn 阅读(146) 评论(0) 推荐(0) 编辑

2013年11月17日

4D

摘要: 1. struct,class ConstructorThe first parameter in the copy constructor has the same type as the class, structure, or union for which it is defined. The first parameter can be a reference to the type but not the type itself.2. struct 与 class区别(1)默认继承权限。如果不明确指定,来自class的继承按照private继承处理,来自struct的继承按照pub 阅读全文

posted @ 2013-11-17 11:18 longhorn 阅读(231) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8

导航