Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

02 2016 档案

摘要:First problem to learn Max Flow. Ford-Fulkerson is a group of algorithms - Dinic is one of it.It is an iterative process: we use BFS to check augament 阅读全文
posted @ 2016-02-17 12:23 Tonix 阅读(383) 评论(0) 推荐(0)

摘要:Here is the mind flow: My intuition was to use Fenwick tree - that works but that's O(nlgn). That's too generalized and the magic number is 3 - that m 阅读全文
posted @ 2016-02-16 15:14 Tonix 阅读(137) 评论(0) 推荐(0)

摘要:A typical recursion use: class Solution(object): max_size = 0 # return: isValid, minVal, maxVal, nodeCnt def go(self, root): if root.left is None and 阅读全文
posted @ 2016-02-12 14:31 Tonix 阅读(276) 评论(0) 推荐(0)

摘要:Intuitive one to learn about Grundy basic :) Now every pile becomes a game, so we need to use Sprague-Grundy Theory. Calculation is quite intuitive - 阅读全文
posted @ 2016-02-11 09:04 Tonix 阅读(313) 评论(0) 推荐(0)

摘要:Please note: VROOK cannot go back-ward - that leads to a simple variation to Game of Nim: just XOR. t = int(input()) for _ in range(t): n = int(input( 阅读全文
posted @ 2016-02-11 05:15 Tonix 阅读(233) 评论(0) 推荐(0)

摘要:A variation to 0-1 Knapsack. (No Python code got fully AC. Python is too slow for this problem) #include <cmath> #include <cstdio> #include <vector> # 阅读全文
posted @ 2016-02-03 14:32 Tonix 阅读(414) 评论(0) 推荐(0)

摘要:https://leetcode.com/discuss/77133/o-n-o-1-after-median-virtual-indexing Please note the "interleaved" version of partial.. nice idea.. 阅读全文
posted @ 2016-02-03 12:36 Tonix 阅读(127) 评论(0) 推荐(0)

摘要:Yes a typical stack based problem. Please take care of corner cases. class Solution { public: bool isValidSerialization(string preorder) { // Get toke 阅读全文
posted @ 2016-02-03 06:08 Tonix 阅读(264) 评论(0) 推荐(0)

摘要:I got lost totally - it is a whole range of numbers! Actually, we can check each number within the range and pick it greedily. https://leetcode.com/di 阅读全文
posted @ 2016-02-01 05:49 Tonix 阅读(138) 评论(0) 推荐(0)