2013年7月5日

combination sum 2

摘要: class Solution { public: void comb(vector &candidates,int pos,vector >& v,int target) { if( target == 0 ){ v.push_back(v.back()); } for( int i=pos; i target ) { return; } if(... 阅读全文

posted @ 2013-07-05 19:46 jumping_grass 阅读(187) 评论(0) 推荐(0)

combination sum

摘要: class Solution { public: void comb(vector &candidates,int pos,vector >& v,int target) { if( target == 0 ){ v.push_back(v.back()); } for( int i=pos; i target ) { return; } v.back().p... 阅读全文

posted @ 2013-07-05 19:29 jumping_grass 阅读(137) 评论(0) 推荐(0)

put queens

摘要: class Solution {public: vector> v; void putqueen(int k,vector &pos) { //cout tmp( pos.size(),s); for(int i=0;i > solveNQueens(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function v.clear(); if( n== 0 ) return v;... 阅读全文

posted @ 2013-07-05 17:46 jumping_grass 阅读(163) 评论(0) 推荐(0)

rotate image

摘要: class Solution {public: void rotate(vector > &matrix) { // Start typing your C/C++ solution below // DO NOT write int main() function if( matrix.size() == 1 ) return; int start = 0; int n = matrix.size(); int tmp = 0; while( start < n ) { ... 阅读全文

posted @ 2013-07-05 16:28 jumping_grass 阅读(97) 评论(0) 推荐(0)

trap rain water

摘要: 1 class Solution { 2 public: 3 int trap(int A[], int n) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if( n==0 )return 0; 7 int volum = 0; 8 stack s; 9 s.push(0);10 int t;11 for(int i=1;i= A[... 阅读全文

posted @ 2013-07-05 11:52 jumping_grass 阅读(150) 评论(0) 推荐(0)

2013年7月4日

Jump Game

摘要: class Solution {public:int jump(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if( n==0 || n == 1 ) return 0; int cur = 0,newCur = 0; int step = 0; while( cur = n-1 ) return step+1; int flag ... 阅读全文

posted @ 2013-07-04 21:36 jumping_grass 阅读(186) 评论(0) 推荐(0)

merge intervals

摘要: 1 bool cmp(Interval a,Interval b) 2 { 3 return a.start merge(vector &intervals) { 8 // Start typing your C/C++ solution below 9 // DO NOT write int main() function10 vector v;11 if( intervals.size() == 1 || intervals.empty() ) return intervals;12 13 ... 阅读全文

posted @ 2013-07-04 20:53 jumping_grass 阅读(147) 评论(0) 推荐(0)

merge interval

摘要: 1 class Solution { 2 public: 3 vector insert(vector &intervals, Interval newInterval) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 vector v; 7 if( intervals.empty () ) { v.push_back(newInterval); return v;} 8 9 ... 阅读全文

posted @ 2013-07-04 20:34 jumping_grass 阅读(188) 评论(0) 推荐(0)

spiral matrix

摘要: 1 class Solution { 2 public: 3 4 vector> generateMatrix(int num) { 5 // Start typing your C/C++ solution below 6 // DO NOT write int main() function 7 8 vector> v(num,vector(num,0)); 9 10 int m ,n;11 m = n = num;12 if( m == 0 )... 阅读全文

posted @ 2013-07-04 17:23 jumping_grass 阅读(135) 评论(0) 推荐(0)

unique paths

摘要: class Solution {public: int rows; int cols; int path(int m,int n, vector> &v) { if( m==rows-1 && n == cols-1 ) return 1; if( v[m][n] != INT_MAX ) return v[m][n]; int way1 = 0,way2 = 0; if( m > v( m, vector(n,INT_MAX)); return path(0,0,v); }};... 阅读全文

posted @ 2013-07-04 14:43 jumping_grass 阅读(116) 评论(0) 推荐(0)

导航