摘要: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
阅读全文
02 2016 档案
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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 -
阅读全文
摘要: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(
阅读全文
摘要: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> #
阅读全文
摘要:https://leetcode.com/discuss/77133/o-n-o-1-after-median-virtual-indexing Please note the "interleaved" version of partial.. nice idea..
阅读全文
摘要:Yes a typical stack based problem. Please take care of corner cases. class Solution { public: bool isValidSerialization(string preorder) { // Get toke
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号