2014年3月13日

Combinations

摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]不知道有没有更好的方法。class Solution {public: vector > re; vector > combine(int n, int k) { vector m; if(n already... 阅读全文

posted @ 2014-03-13 21:06 pengyu2003 阅读(126) 评论(0) 推荐(0)

Search a 2D Matrix

摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, 3, ... 阅读全文

posted @ 2014-03-13 19:42 pengyu2003 阅读(165) 评论(0) 推荐(0)

导航