会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
卖程序的小歪
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
36
37
38
39
40
41
42
43
44
···
46
下一页
2014年4月17日
LeetCode Rotate List
摘要: 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 卖程序的小歪
阅读(161)
评论(0)
推荐(0)
2014年4月16日
LeetCode Divide Two Integers
摘要: 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 卖程序的小歪
阅读(182)
评论(0)
推荐(0)
LeetCode 3Sum
摘要: class Solution {public: vector > threeSum(vector &num) { vector > res; int len = num.size(); sort(num.begin(), num.end()); ...
阅读全文
posted @ 2014-04-16 19:49 卖程序的小歪
阅读(136)
评论(0)
推荐(0)
Leetcode 4Sum
摘要: 先来一个暴力解:class Solution {public: vector > fourSum(vector &num, int target) { vector > res; vector r; r.resize(4); sort(n...
阅读全文
posted @ 2014-04-16 09:34 卖程序的小歪
阅读(155)
评论(0)
推荐(0)
2014年4月15日
Implementation:UnionFindSet 并查集
摘要: class UnionFindSet { private: int *pref; int *rank; int capacity; public: UnionFindSet(int n) { if (n = c...
阅读全文
posted @ 2014-04-15 21:26 卖程序的小歪
阅读(171)
评论(0)
推荐(0)
Implementation:Dijkstra
摘要: #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 卖程序的小歪
阅读(180)
评论(0)
推荐(0)
Implementation:Bellman-ford
摘要: 单源最短路径算法Bellman-ford练习,可以处理有负边的情况(也可以在存在负圈时及时终止)#include #include #include using namespace std;class Edge {public: int from; int to; int cost...
阅读全文
posted @ 2014-04-15 19:45 卖程序的小歪
阅读(146)
评论(0)
推荐(0)
Implementation:Binary Indexed Tree 树状数组
摘要: #include #include using namespace std;class BinaryIndexedTree {private: int *mem; int capacity;public: BinaryIndexedTree (int n) { if ...
阅读全文
posted @ 2014-04-15 16:11 卖程序的小歪
阅读(150)
评论(0)
推荐(0)
2014年4月14日
LeetCode Largest Rectangle in Histogram
摘要: class SegmentTree { private: int *mem; int *idx; int capacity; int storage_size; private: void init_level_upd...
阅读全文
posted @ 2014-04-14 23:57 卖程序的小歪
阅读(175)
评论(0)
推荐(0)
Implementation:Segment Tree 线段树
摘要: 早就听人提起过线段树,今天有题搞不出来,讨论上说要用一下线段树,看了下,本质上是空间划分索引,只不过是一维上面的,如果在二维则是四叉树,三维则是八叉树,如果可以动态调整那么跟R-Tree就很相似了,他们都可以对范围查询做出响应。参照书上写了一个,虽然不多,但是渣渣也写的很是费力#include #i...
阅读全文
posted @ 2014-04-14 19:07 卖程序的小歪
阅读(225)
评论(0)
推荐(0)
上一页
1
···
36
37
38
39
40
41
42
43
44
···
46
下一页
公告