Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 25 下一页

2016年1月27日

摘要: Just for study from its editorial~Lesson learnt: an optimized Hungarian Algorithm: Hopcroft-Karp Algorithm (a batched version of Hungarian)A very good... 阅读全文
posted @ 2016-01-27 14:32 Tonix 阅读(332) 评论(0) 推荐(0)

摘要: Interesting Greedy.. classichttps://leetcode.com/discuss/75529/c-simple-solution-easy-understandingclass Solution {public: string removeDuplicateLe... 阅读全文
posted @ 2016-01-27 07:47 Tonix 阅读(182) 评论(0) 推荐(0)

摘要: My naive Fenwick solution (value space) failed with the last test case in which there's INT_MIN\INT_MAX..So I learnt a smarter thought on Fenwick:http... 阅读全文
posted @ 2016-01-27 05:57 Tonix 阅读(205) 评论(0) 推荐(0)

2016年1月23日

摘要: Visualize the unzip process.class Solution {public: ListNode* oddEvenList(ListNode* head) { if (!head || !head->next) return head; Li... 阅读全文
posted @ 2016-01-23 06:28 Tonix 阅读(198) 评论(0) 推荐(0)

2016年1月6日

摘要: Nothing special. Point is, how clean can you do it?class Solution {public: int maxSubArrayLen(vector& nums, int k) { int n = nums.size()... 阅读全文
posted @ 2016-01-06 18:33 Tonix 阅读(162) 评论(0) 推荐(0)

摘要: 1AC. Intuitive DP. But please note the if condition, there's a trick - we cannot build upon an invalid dp slot.class Solution {public: int coinChan... 阅读全文
posted @ 2016-01-06 18:29 Tonix 阅读(194) 评论(0) 推荐(0)

2015年12月22日

摘要: Nothing magic here. Just BFS, but - BFS from land is not a good idea - BFS from Buildings.Lesson learnt: reverse thinking helps!class Solution {public... 阅读全文
posted @ 2015-12-22 07:22 Tonix 阅读(331) 评论(0) 推荐(0)

2015年12月19日

摘要: https://leetcode.com/discuss/75014/math-solutionLesson learnt: dig deeper! 阅读全文
posted @ 2015-12-19 15:18 Tonix 阅读(158) 评论(0) 推荐(0)

2015年12月17日

摘要: Another O(n^2) solution using bit ops. We prune 1/2(expected) candidates at each bit check.#define MAX_BITS 1600typedef bitset CandMask;class Solution... 阅读全文
posted @ 2015-12-17 04:16 Tonix 阅读(258) 评论(0) 推荐(0)

2015年12月16日

摘要: What a classic DP problem..https://leetcode.com/discuss/72216/share-some-analysis-and-explanations 阅读全文
posted @ 2015-12-16 14:09 Tonix 阅读(148) 评论(0) 推荐(0)

摘要: A classic type of problem: multi-pointer marching algorithm. For each pointer of each prime, we need to remember where it is in the ugly sequence, so ... 阅读全文
posted @ 2015-12-16 04:35 Tonix 阅读(186) 评论(0) 推荐(0)

2015年12月15日

摘要: Almost identical to LintCode "Count of Smaller Number before Self". Corner case needs to be taken care of.class Solution { ////////////////// //... 阅读全文
posted @ 2015-12-15 13:55 Tonix 阅读(172) 评论(0) 推荐(0)

摘要: BFS + HashTableclass Solution { int maxl, minl; unordered_map> hm;public: vector> verticalOrder(TreeNode* root) { maxl = INT_MIN; ... 阅读全文
posted @ 2015-12-15 12:26 Tonix 阅读(147) 评论(0) 推荐(0)

2015年11月30日

摘要: Taking advantage of 'sparse'class Solution {public: vector> multiply(vector>& A, vector>& B) { vector> ret; int ha = A.si... 阅读全文
posted @ 2015-11-30 07:38 Tonix 阅读(444) 评论(0) 推荐(0)

2015年11月26日

摘要: Simple data structure but not that easy to figure out.. MHT -> balanced tree.https://leetcode.com/problems/minimum-height-trees/Lesson learnt: Focus o... 阅读全文
posted @ 2015-11-26 16:02 Tonix 阅读(190) 评论(0) 推荐(0)

摘要: A sly knapsack problem in disguise! Thanks tohttps://github.com/bhajunsingh/programming-challanges/tree/master/hackerrank/algorithms/the-indian-jobLes... 阅读全文
posted @ 2015-11-26 08:44 Tonix 阅读(303) 评论(0) 推荐(0)

摘要: I had the same BFS idea as one of the AC code this: because dying pattern is spead from the initial dying ones :)#include #include #include using name... 阅读全文
posted @ 2015-11-26 07:10 Tonix 阅读(1005) 评论(0) 推荐(0)

摘要: Learnt from here:http://www.cnblogs.com/lautsie/p/3798165.htmlIdea is: we union all pure black edges so we get 1+ pure black edge groups. Then we can ... 阅读全文
posted @ 2015-11-26 03:51 Tonix 阅读(244) 评论(0) 推荐(0)

摘要: Very good DP one.First I figured out a O(n^2) solution:class Solution {public: int maxProfit(vector& prices) { int n = prices.si... 阅读全文
posted @ 2015-11-26 02:47 Tonix 阅读(247) 评论(0) 推荐(0)

2015年11月23日

摘要: Actually I think problem statement is somewhat misleading. No need to mention range [L, R] at all.The intention is a variation to "Largest Rectangle" ... 阅读全文
posted @ 2015-11-23 15:49 Tonix 阅读(249) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 25 下一页