摘要:
Really interesting O(n) problem. Just like playing.. so actually working on algorithm problems is like playing games!class Solution {public: int ma... 阅读全文
摘要:
One TopCoder article introduces a very interesting alternative solution to Longest Common Sequences problem.It is based on this statement (http://comm... 阅读全文
摘要:
Binary Tree *-order traversal by recursion is trivial. But their iteration version deserves a look:Pre-Orderclass Solution { vector ret;public: ... 阅读全文
摘要:
Just reimplemented the solution to this classic problem using Manacher algorithm in my mind. So neat idea :)class Solution {public: string longestP... 阅读全文
摘要:
Similar with version I, but analysis is different. With the possibility of duplication, only ">" indicate a definite case of next search space.class S... 阅读全文
摘要:
There's usually a common strategy for "find *" problems - binary search: half the space can be dropped by some rules.And take care of corner cases.cla... 阅读全文
摘要:
http://www.zhihu.com/question/26547156Tango Tree Taking advantage of cache locality. 'Preferred path' is a recently access searching path (which is w... 阅读全文
摘要:
Not very hard to figure out an initial solution, with min heap\monoq\stack. But the key idea is to avoid unnecessary book-keeping when new value is la... 阅读全文
摘要:
1. LC\EPI summary Quick Sort: in C and in Haskell2. G's slides NP-Complete: salesman\knapsack(encrypted) http://blog.csdn.net/liyangbing315/artic... 阅读全文
摘要:
Intuitively there must a O(n) solution.First I tried a bottom-up DP solution but it had a TLE:class Solution {public: int maxProduct(int A[], int n... 阅读全文
摘要:
We compare two end' (current) chars and the key is how to check when there's a mismatch - DFS.#include #include #include #include #include #include us... 阅读全文
摘要:
A natural thought is brutal-force. But as you may have already thought of, there must be a smarter one. And yes there is.Think like this: XOR gives yo... 阅读全文
摘要:
Man it took me numerous submissions to get AC, and I referred to this link:http://yihuad.blogspot.com/2013/11/word-ladder-ii-leetcode.htmlIdea is pret... 阅读全文
摘要:
My intuition is flood-fill the BFS solution, which is O(n^4); and then I figured out a DP solution which is O(n^4).. So I googled some hints: it can b 阅读全文
摘要:
I have to admit that I'm still an algorithm rookie: in front of a problem, I got lost on what the nature of the problem is.. usually I made everything... 阅读全文
摘要:
A really classic 2D DP problem. And I'm glad that I figured out the transfer function without checking any other resources.After that, everything is s... 阅读全文