上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 46 下一页
摘要: class Solution {public: ListNode *rotateRight(ListNode *head, int k) { if (head == NULL) return NULL; ListNode *p = head, *q = head; ... 阅读全文
posted @ 2014-04-17 16:55 卖程序的小歪 阅读(155) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int divide(int dividend, int divisor) { bool aneg = dividend a || a == 0) return 0; unsigned int abits = 0, ... 阅读全文
posted @ 2014-04-16 21:18 卖程序的小歪 阅读(176) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: vector > threeSum(vector &num) { vector > res; int len = num.size(); sort(num.begin(), num.end()); ... 阅读全文
posted @ 2014-04-16 19:49 卖程序的小歪 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 先来一个暴力解:class Solution {public: vector > fourSum(vector &num, int target) { vector > res; vector r; r.resize(4); sort(n... 阅读全文
posted @ 2014-04-16 09:34 卖程序的小歪 阅读(149) 评论(0) 推荐(0) 编辑
摘要: class UnionFindSet { private: int *pref; int *rank; int capacity; public: UnionFindSet(int n) { if (n = c... 阅读全文
posted @ 2014-04-15 21:26 卖程序的小歪 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;typedef pair P;int main() { // zero means no connection int graph[5][5] = { ... 阅读全文
posted @ 2014-04-15 19:49 卖程序的小歪 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 单源最短路径算法Bellman-ford练习,可以处理有负边的情况(也可以在存在负圈时及时终止)#include #include #include using namespace std;class Edge {public: int from; int to; int cost... 阅读全文
posted @ 2014-04-15 19:45 卖程序的小歪 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;class BinaryIndexedTree {private: int *mem; int capacity;public: BinaryIndexedTree (int n) { if ... 阅读全文
posted @ 2014-04-15 16:11 卖程序的小歪 阅读(143) 评论(0) 推荐(0) 编辑
摘要: class SegmentTree { private: int *mem; int *idx; int capacity; int storage_size; private: void init_level_upd... 阅读全文
posted @ 2014-04-14 23:57 卖程序的小歪 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 早就听人提起过线段树,今天有题搞不出来,讨论上说要用一下线段树,看了下,本质上是空间划分索引,只不过是一维上面的,如果在二维则是四叉树,三维则是八叉树,如果可以动态调整那么跟R-Tree就很相似了,他们都可以对范围查询做出响应。参照书上写了一个,虽然不多,但是渣渣也写的很是费力#include #i... 阅读全文
posted @ 2014-04-14 19:07 卖程序的小歪 阅读(217) 评论(0) 推荐(0) 编辑
上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 46 下一页