会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
ying_vincent
博客园
首页
新随笔
联系
管理
订阅
上一页
1
2
3
4
5
6
7
8
9
···
27
下一页
2014年10月8日
LeetCode: Maximum Product Subarray
摘要: 很久没练只能看别人代码了 1 class Solution { 2 public: 3 int maxProduct(int A[], int n) { 4 if (n == 0) return 0; 5 int curMax, curMin, ans; 6 ...
阅读全文
posted @ 2014-10-08 21:59 ying_vincent
阅读(134)
评论(0)
推荐(0)
2014年4月28日
LeetCode: Reverse Words in a String
摘要: 先来一个需要extra space的 1 class Solution { 2 public: 3 void reverseWords(string &s) { 4 vector S; 5 int pre = 0; 6 string tmp =...
阅读全文
posted @ 2014-04-28 12:26 ying_vincent
阅读(138)
评论(0)
推荐(0)
2014年4月21日
Data Structure Graph: strong connectivity
摘要: 如果为undirected graph就是dfs或者bfs,如果都能visit则为连通O(V+E).如果为directed graph就先dfs或者bfs,再reverse direct,再dfs或者bfs,如果两次都连通则为strong connecthttp://www.geeksforgeek...
阅读全文
posted @ 2014-04-21 04:11 ying_vincent
阅读(132)
评论(0)
推荐(0)
2014年4月19日
Data Structure Graph: strong connectivity
摘要: 如果为undirected graph就是dfs或者bfs,如果都能visit则为连通O(V+E).如果为directed graph就先dfs或者bfs,再reverse direct,再dfs或者bfs,如果两次都连通则为strong connecthttp://www.geeksforgeek...
阅读全文
posted @ 2014-04-19 11:04 ying_vincent
阅读(195)
评论(0)
推荐(0)
Data Structure Graph: prim
摘要: 最小生成树算法。这里的s是可以随意选取的,不影响树的生成,但是不同的s有不同的dis 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; ...
阅读全文
posted @ 2014-04-19 07:24 ying_vincent
阅读(246)
评论(0)
推荐(0)
Data Structure Graph: cycle in a directed graph
摘要: geeks上的解答复杂了些,用回溯就行了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 const int N = 5;1...
阅读全文
posted @ 2014-04-19 04:45 ying_vincent
阅读(237)
评论(0)
推荐(0)
Data Structure Trie: suffix problem
摘要: http://www.geeksforgeeks.org/suffix-array-set-1-introduction/http://www.geeksforgeeks.org/pattern-searching-set-8-suffix-tree-introduction/https://en....
阅读全文
posted @ 2014-04-19 03:09 ying_vincent
阅读(122)
评论(0)
推荐(0)
2014年4月13日
Data Structure Stack: Reverse a stack using recursion
摘要: http://www.geeksforgeeks.org/reverse-a-stack-using-recursion/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 12 void insertbottom(stack &S, int top) {13 if (S.empty()) S.push(top);14 else {15 int tm...
阅读全文
posted @ 2014-04-13 10:22 ying_vincent
阅读(224)
评论(0)
推荐(0)
2014年4月12日
Data Structure Stack: Infix to Postfix
摘要: http://geeksquiz.com/stack-set-2-infix-to-postfix/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 12 bool isoprand(char x) {13 return x >= 'A' && x = 'a' && x T;26 for (int i = 0; i <
阅读全文
posted @ 2014-04-12 03:50 ying_vincent
阅读(240)
评论(0)
推荐(0)
2014年4月11日
Data Structure Linked List: Flattening a Linked List
摘要: http://www.geeksforgeeks.org/flattening-a-linked-list/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 using namespace std;11 12 struct node {13 int data;14 node *right;15 node *down;16 node(int d = 0) : data(d), right(NUL...
阅读全文
posted @ 2014-04-11 12:09 ying_vincent
阅读(168)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
27
下一页