Tony's Log

Algorithms, Distributed System, Machine Learning

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

2014年7月18日

摘要: Since no order requirement, we can simply swap the target value to the last non-target-value in the array - if the last non-target-value is not behind... 阅读全文
posted @ 2014-07-18 13:35 Tonix 阅读(120) 评论(0) 推荐(0)

摘要: The best way to learn DP from DFS! Nice problem.My intuition is that it can be solved by DFS:class Solution {public: int climbStairs(int n) { ... 阅读全文
posted @ 2014-07-18 12:49 Tonix 阅读(162) 评论(0) 推荐(0)

摘要: Not very hard to figure out the solution: splitting the list into 2 halves; reverse the 2nd half and interleave the two halves.But it takes some time ... 阅读全文
posted @ 2014-07-18 04:10 Tonix 阅读(152) 评论(0) 推荐(0)

摘要: The key of this problem is about details especially boundary conditions.class Solution {public: ListNode *deleteDuplicates(ListNode *head) { ... 阅读全文
posted @ 2014-07-18 01:01 Tonix 阅读(129) 评论(0) 推荐(0)

2014年7月17日

摘要: This is to test your knowledge on BST and its traversal.Flatting BST into an array using in-order, and check that array. It is that simple:class Solut... 阅读全文
posted @ 2014-07-17 15:44 Tonix 阅读(145) 评论(0) 推荐(0)

摘要: This is the same asSPOJ #453. The best way to understand DP1A code:class Solution {public: int minimumTotal(vector > &triangle) { fo... 阅读全文
posted @ 2014-07-17 06:21 Tonix 阅读(145) 评论(0) 推荐(0)

摘要: A typical DFS usage, no big deal:class Solution {public: int dfs(TreeNode *p, int pval) { if( !p->left && !p->right ) { ... 阅读全文
posted @ 2014-07-17 05:27 Tonix 阅读(151) 评论(0) 推荐(0)

2014年7月16日

摘要: It is not a big deal at the first sight:https://oj.leetcode.com/problems/single-number/And my AC code is straightforward:#include using namespace std... 阅读全文
posted @ 2014-07-16 15:39 Tonix 阅读(148) 评论(0) 推荐(0)

摘要: First, 写POJ的报告用毛英文啊...这道题思路不算难,主要参考了这里:http://www.cnblogs.com/damacheng/archive/2010/09/24/1833983.html讲得很清楚,但是代码有点复杂,我个人觉得不需要:循环情况可以当作非循环的一个特殊情况,简单处理... 阅读全文
posted @ 2014-07-16 12:04 Tonix 阅读(445) 评论(0) 推荐(0)

2014年7月15日

摘要: This is really classic searching problem to solve. The key is pruning.(My reference:http://blog.csdn.net/lyy289065406/article/details/6647960)There ar... 阅读全文
posted @ 2014-07-15 06:27 Tonix 阅读(197) 评论(0) 推荐(0)

2014年7月7日

摘要: Good reference:http://www.cppblog.com/sdfond/archive/2009/07/31/91761.htmlIt is a classic coverage\dp compression problem. Initially I thought of dp[i... 阅读全文
posted @ 2014-07-07 04:23 Tonix 阅读(182) 评论(0) 推荐(0)

2014年7月5日

摘要: I tried several solutions except the one fromhttp://love-oriented.com/pack/P03.html (wonderful resource to learn DP), but all failed with WA\TLE. Afte... 阅读全文
posted @ 2014-07-05 04:44 Tonix 阅读(184) 评论(0) 推荐(0)

2014年7月1日

摘要: DP is, enumeration + pruning. If you can think of enumeration pattern of a problem, plus a recurrence relation later, you are there.Main ref:http://bl... 阅读全文
posted @ 2014-07-01 14:02 Tonix 阅读(125) 评论(0) 推荐(0)

2014年6月30日

摘要: http://hi.baidu.com/zldiablo/item/32f3e614de94f48d88a9560dNot very easy to identify the dp recurrence relation at first sight.. but strip your artific... 阅读全文
posted @ 2014-06-30 13:16 Tonix 阅读(166) 评论(0) 推荐(0)

2014年6月28日

摘要: A classic 2D DP problem. A disguise of LCS - actually not very hard to decode: it is about 2 sequences' matching, though with a weight value of each m... 阅读全文
posted @ 2014-06-28 14:24 Tonix 阅读(183) 评论(0) 推荐(0)

2014年6月25日

摘要: Looks quite intuitive at the very first sight... I thought:rect[x, y, w+1, h+1] = rect[x, y, w, h] + num[x + w + 1, y..y+h+1] + num[x..x+w+1, y+h+1] -... 阅读全文
posted @ 2014-06-25 14:19 Tonix 阅读(201) 评论(0) 推荐(0)

2014年6月24日

摘要: I can feel that I am making great progress now.. if inspected closely, it is obvious that what I'm getting through is, a newbie phase:coding details m... 阅读全文
posted @ 2014-06-24 14:29 Tonix 阅读(110) 评论(0) 推荐(0)

摘要: A bottom-up DP. To be honest, it is not easy to relate DP to this problem. Maybe, all "most"\"least" problems can be solved using DP..Reference:http:/... 阅读全文
posted @ 2014-06-24 14:22 Tonix 阅读(180) 评论(0) 推荐(0)

2014年6月23日

摘要: I used DP instead of Greedy. But got WA on PoJ, though it passed all web-searched cases. Maybe I have to use Greedy.BTW: a careless modification intro... 阅读全文
posted @ 2014-06-23 13:14 Tonix 阅读(229) 评论(0) 推荐(0)

摘要: (poj.org issue. Not submitted yet)This is a 2D DP problem, very classic too. Since I'm just learning, so I took this link as reference:http://blog.csd... 阅读全文
posted @ 2014-06-23 07:01 Tonix 阅读(164) 评论(0) 推荐(0)