摘要: https://leetcode.com/problems/ransom-note/ public class Solution { public boolean canConstruct(String ransomNote, String magazine) { char[] chRan = ransomNote.toCharArray(); char... 阅读全文
posted @ 2016-08-28 12:10 blcblc 阅读(140) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/linked-list-random-node/ // Using Reservoir sampling algorithm // https://discuss.leetcode.com/topic/53812/using-reservoir-sampling-o-1-space-o-n-time-complexity-c/2 /... 阅读全文
posted @ 2016-08-28 11:24 blcblc 阅读(206) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/ public class RandomizedCollection { ArrayList nums; HashMap> locs; java.util.Random rand; /** Initialize... 阅读全文
posted @ 2016-08-27 23:58 blcblc 阅读(342) 评论(0) 推荐(0) 编辑
摘要: <!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> http://www.cnblogs.com/lovebread/archive/2009/11/24/1609936.html 阅读全文
posted @ 2016-08-22 11:03 blcblc 阅读(317) 评论(0) 推荐(0) 编辑
摘要: // 参考了下面一些讨论的解法 // https://discuss.leetcode.com/topic/53235/java-with-hashtable-arraylist/2 class RandomizedSet { vector vec; unordered_map umap; public: /** Initialize your data structu... 阅读全文
posted @ 2016-08-04 22:59 blcblc 阅读(259) 评论(0) 推荐(0) 编辑
摘要: //有很多讨论,比如 // https://discuss.leetcode.com/topic/52865/my-solution-using-binary-search-in-c // https://discuss.leetcode.com/topic/52912/binary-search-heap-and-sorting-comparison-with-concise-code-and... 阅读全文
posted @ 2016-08-02 14:41 blcblc 阅读(231) 评论(0) 推荐(0) 编辑
摘要: #include class Solution { unordered_map dp_map; vector vec; int func(int target) { if (dp_map.find(target) != dp_map.end()) { return dp_map[target]; ... 阅读全文
posted @ 2016-08-01 15:22 blcblc 阅读(185) 评论(0) 推荐(0) 编辑
摘要: // 参考了:https://discuss.leetcode.com/topic/51893/two-solutions-one-is-dp-the-other-is-greedy-8-lines // 另有:https://discuss.leetcode.com/topic/51946/very-simple-java-solution-with-detail-explanation c... 阅读全文
posted @ 2016-08-01 14:06 blcblc 阅读(387) 评论(0) 推荐(0) 编辑
摘要: 【本文系外部转贴,原文地址:http://coolshell.info/c/c++/2014/12/13/c-open-project.htm】 下次造轮子前先看看现有的轮子吧 值得学习的C语言开源项目 - 1. Webbench Webbench是一个在linux下使用的非常简单的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模... 阅读全文
posted @ 2016-07-25 15:05 blcblc 阅读(22738) 评论(0) 推荐(0) 编辑
摘要: // https://discuss.leetcode.com/topic/51353/simple-dp-solution-with-explanation // https://en.wikipedia.org/wiki/Minimax // 开始我的思路有问题,我是先选择区间,最后收敛到结果数 // 实际上work的思路是,先选择数字,再走向某个区间,然后取两个区间中的更大值 class... 阅读全文
posted @ 2016-07-18 14:50 blcblc 阅读(154) 评论(0) 推荐(0) 编辑