摘要: 从今天开始学js 阅读全文
posted @ 2013-11-08 18:06 代码改变未来 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1.Subsets代码1:class Solution {public: vector > subsets(vector &S) { vector>v; vectorv2(S.size(),0); sort(S.begin(),S.end()); subset(v,S,0,v2); return v; } void subset(vector> &v,vector &S,int cur,vector &v2) { if(cur==S.size()) { ... 阅读全文
posted @ 2013-09-09 20:57 代码改变未来 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 1.Largest Rectangle in Histogramhttp://discuss.leetcode.com/questions/259/largest-rectangle-in-histogramhttp://www.cnblogs.com/remlostime/archive/2012/11/25/2787359.html2.Minimum Window Substringhttp://discuss.leetcode.com/questions/97/minimum-window-substringhttp://www.cnblogs.com/remlostime/archiv 阅读全文
posted @ 2013-09-05 19:23 代码改变未来 阅读(202) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: bool isScramble(string s1, string s2) { int n = s1.size(); if (s2.size() != n) return false; bool f[n][n][n]; for (int i=0; i<n; i++) for (int j=0; j<n; j++) f[i][j][0] = s1[i] == s2[j]; for (int l=1; l<n; l++) ... 阅读全文
posted @ 2013-09-05 19:08 代码改变未来 阅读(261) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public ArrayList generateTrees(int n) { return generateTrees(1, n); } public ArrayList generateTrees(int start, int end){ ArrayList unique = new ArrayList(); if(start > end){ unique.add(null); return unique; } ... 阅读全文
posted @ 2013-09-05 19:03 代码改变未来 阅读(1316) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int calLen(ListNode *node) { int len = 0; while(node) { len++; node = node->next; } return len; } TreeNode *createTree(ListNode *node, int left, int right) { if (left > right) return NU... 阅读全文
posted @ 2013-09-05 18:42 代码改变未来 阅读(280) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int trap(int A[], int n) { if(n==0)return 0; vectorleft(n); int maxHeight = 0; for(int i = 0; i right(n); maxHeight = 0; for(int i = n - 1; i >= 0; i--) { right[i] = maxHeight; maxHeight = max(maxHeigh... 阅读全文
posted @ 2013-09-05 15:39 代码改变未来 阅读(246) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int numTrees(int n) { vector v(n+1, 0); v[0] = 1; v[1] = 1; v[2] = 2; if(n<=2) return v[n]; for(int i=3; i<=n; i++) for(int j=1; j<=i; j++) v[i] += v[j-1]*v[i-j]; return v[n]; ... 阅读全文
posted @ 2013-09-04 14:37 代码改变未来 阅读(125) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: ListNode *swapPairs(ListNode *head) { if(head==NULL)return NULL; ListNode *p=head,*ppre=head,*pnext; while(p&&p->next) { pnext=p->next; if(pnext) { if(ppre==head)head=pnext; else... 阅读全文
posted @ 2013-09-04 12:01 代码改变未来 阅读(180) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int minimumTotal(vector > &triangle) { if (triangle.size() == 0) return 0; vector f(triangle[triangle.size()-1].size()); f[0] = triangle[0][0]; for(int i = 1; i = 0; j--) if (j == 0) f[j] = f[j] + triangle[i][j]; else if (j == t... 阅读全文
posted @ 2013-09-03 21:08 代码改变未来 阅读(234) 评论(0) 推荐(0) 编辑