红桃J

用心写好每行完美的代码,远比写一堆更有价值

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2015年4月15日

摘要: 问题解法参考它给出了这个问题的探讨。超时的代码:这个当n等于7时,已经要很长时间出结果了。这个算法的复杂度是O(n^2)。#include#include#include#includeusing namespace std;bool isValid(string s) { map smap;... 阅读全文
posted @ 2015-04-15 11:37 红桃J 阅读(148) 评论(0) 推荐(0) 编辑

摘要: 代码: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 bool isValid(string s) { 8 map smap; 9 smap.insert(make_pair('(', ')'));10... 阅读全文
posted @ 2015-04-15 10:31 红桃J 阅读(99) 评论(0) 推荐(0) 编辑

摘要: 代码: 1 #include 2 3 using namespace std; 4 5 struct ListNode { 6 int val; 7 ListNode *next; 8 ListNode(int x) : val(x), next(NULL) {} 9 }... 阅读全文
posted @ 2015-04-15 00:44 红桃J 阅读(138) 评论(0) 推荐(0) 编辑

摘要: 对这种问题进行一下小结也算是对昨天写错leetcode Generate Parentheses的一个反省。这也是一个用递归去填数组的问题,在这里就意识到了一次递归填一个,可能是受到这个题的影响所以才会出现在leetcode Generate Parentheses里的问题,果然和大神们还是有不小差... 阅读全文
posted @ 2015-04-15 00:00 红桃J 阅读(138) 评论(0) 推荐(0) 编辑