上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页
摘要: Bottom-up 较难的题目1. 和 google code jam 分数那题差不多, 需要用到 &TreeNode* buildTree(ListNode* &head, int st, int ed) { if(st > ed) return NULL; int mid = (st+ed)>... 阅读全文
posted @ 2014-04-24 08:25 周卓 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 对本科使用的数据结构课本感情很深, 当初学的时候, 并不需要上机编程, 考试时只需写出伪代码即可. 而今, 实现的细节已经变得必须了, 所以, 再次拿出课本, 复习一下实现细节数据结构和算法1. 堆的实现(插入, 删除, 初始化, 以最大根为例)2. 快排的实现3. 归并排序的实现4. 数组实现队列... 阅读全文
posted @ 2014-04-24 07:05 周卓 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 题目思路1. WA 了十次2.// e9 False// .1 true// 3. true// . false// 343e+34 true3. 分成了三个部分, 三部分之间有较弱的依赖关系, 还可以通过 bool 变量与返回值分开代码bool pa, pb, pc;int FurtherA(co... 阅读全文
posted @ 2014-04-23 23:59 周卓 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题目总结1. 本身不是太难, 难的是想到好的切入点2. 所有的代码读入后再做处理3. 以 '/' 作为分隔符, 作检查代码vector nest;vector del;nest.clear();del.clear();int pos = -1;for(int i = 0; i 0 && text[... 阅读全文
posted @ 2014-04-23 13:56 周卓 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 题目总结1. 得到一个教训, 对于模拟题来说, 需要检查为空和越界两种情况2. look ahead 在自动机类型题目中是非常必要的, 要根据两个字符来判断控制流的走向代码class Solution {public: bool isMatch(const char *s, const cha... 阅读全文
posted @ 2014-04-23 12:57 周卓 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 题目总结1. 做这种题时需要考虑 corner case, 比如连续几个 slash2. 状态函数带参数 (int &pos), 主函数带 while 循环 while(pos record; int i = 0; int len = path.size(); while(i <... 阅读全文
posted @ 2014-04-23 10:30 周卓 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 题目总结1. int 的问题上升到 long long 以减少判断2. longlong int BIG_INT 不能通过 10 * INT_MAX 获得, 必须手动指定int conversion(const char *substr, bool neg) { int len = strlen(s... 阅读全文
posted @ 2014-04-22 22:51 周卓 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Chapter One 策略模式 1. 鸭子要加入 fly() 函数, 于是考虑在基类 duck中加入虚函数分别在子类予以实现. 但结论却是, 当涉及维护时, 为了复用目的而是用继承, 结局并不完美.2. 考虑使用接口, 比如有一个 flyable(), Quackable() 等等, 只有会飞的鸭子才继承 Flyable 接口中. 但这种方法会造成代码无法重用.结论, 软件开发上的不变真理是 ... 阅读全文
posted @ 2014-04-22 11:16 周卓 阅读(150) 评论(0) 推荐(0) 编辑
摘要: WA1. 函数体内用的是从 1 开始的数组, 而接受的 input 是从 0 开始的, 又是好2的错误代码#include #include #include #include #include #include #include #include #include #include #define... 阅读全文
posted @ 2014-04-21 21:55 周卓 阅读(161) 评论(0) 推荐(0) 编辑
摘要: WA1. 写出了 dist[][] 数组和 minDist() 函数, 实现了 minDist 函数但最终却是使用了 dist 数组不一致代码#include #include #include #include #include #include #include #include #includ... 阅读全文
posted @ 2014-04-21 15:21 周卓 阅读(135) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页