上一页 1 2 3 4 5 6 ··· 17 下一页

死锁的简单实现

摘要: 死锁的四个必要条件:1. 互斥:资源不能多线程共享2. 不剥夺:线程不能强行剥夺其他线程持有的资源3. 请求与保持:线程请求它所需要的资源时,继续保持自己已持有的资源4. 环路等待:这个比较容易理解,多个线程的请求之间形成了一个环路。如果不理解,请看下面一个段子:【女儿】:妈妈,明早我要考试,5点钟... 阅读全文
posted @ 2014-09-22 17:04 喵星人与汪星人 阅读(229) 评论(0) 推荐(0) 编辑

生产者消费者问题

摘要: public class Depot { int capacity ; int size; public Depot(int capacity){ this.capacity = capacity; this.size = 0; } ... 阅读全文
posted @ 2014-09-22 16:39 喵星人与汪星人 阅读(152) 评论(0) 推荐(0) 编辑

[leecode]Implement strStr()

摘要: Implement strStr()Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.实现String... 阅读全文
posted @ 2014-09-14 23:13 喵星人与汪星人 阅读(189) 评论(0) 推荐(0) 编辑

KMP算法小结

摘要: 今天又把KMP算法看了一遍,特此小结。扯淡的话:KMP算法主要用来模式匹配。正如Implement strStr()中形容的一样,“大海捞针”,当时看到题中变量如此命名,真的感觉实在是再贴切不过了。在介绍KMP算法之前,先介绍一下BF算法,叫的这么暧昧(who is GF?),其实就是最low的暴力... 阅读全文
posted @ 2014-09-14 22:45 喵星人与汪星人 阅读(1021) 评论(0) 推荐(0) 编辑

[leecode]Scramble String

摘要: Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible... 阅读全文
posted @ 2014-09-01 23:38 喵星人与汪星人 阅读(146) 评论(0) 推荐(0) 编辑

[leecode]Binary Tree Preorder Traversal

摘要: Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文
posted @ 2014-08-31 17:48 喵星人与汪星人 阅读(184) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree InorderTraversal

摘要: Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文
posted @ 2014-08-31 17:44 喵星人与汪星人 阅读(159) 评论(0) 推荐(0) 编辑

[leecode]Best Time to Buy and Sell Stock III

摘要: Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the... 阅读全文
posted @ 2014-08-26 17:20 喵星人与汪星人 阅读(191) 评论(0) 推荐(0) 编辑

[leecode]Clone Graph

摘要: Clone GraphClone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are l... 阅读全文
posted @ 2014-08-25 20:55 喵星人与汪星人 阅读(180) 评论(0) 推荐(0) 编辑

[leecode]Word Break II

摘要: Word Break IIGiven a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all... 阅读全文
posted @ 2014-08-24 22:49 喵星人与汪星人 阅读(283) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 17 下一页