摘要: Since it need the min value of initial health, this dp tracks from the back to the start.The trick is either this knight has 1 health or base on next ... 阅读全文
posted @ 2015-03-19 08:38 keepshuatishuati 阅读(143) 评论(0) 推荐(0) 编辑
摘要: There couple of edge cases need to remember:1. The result, absolute value of dividend and divisor. Otherwise, when the record goes out of boundary, th... 阅读全文
posted @ 2015-03-19 08:00 keepshuatishuati 阅读(107) 评论(0) 推荐(0) 编辑
摘要: This DP is a little bit tricky. You need to clear that:when S[i-1] == T[j-1], it has two part :1. dp[i-1][j-1], this means from 0 - j-1, it already ma... 阅读全文
posted @ 2015-03-19 07:44 keepshuatishuati 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Simple DP.Scanning from the end. If current is 0, then no decode way as "0", but it can be treated as "10", "20". So do another check whether it can h... 阅读全文
posted @ 2015-03-19 07:27 keepshuatishuati 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Pretty straight forward. count numbers and put char. 1 class Solution { 2 public: 3 string getNext(string s) { 4 ostringstream oss; 5 ... 阅读全文
posted @ 2015-03-19 07:20 keepshuatishuati 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Two methods for doing this problem:1. With extra memory, using hashtable:I made a mistake for mapping[runner->random] = mapping[runner]->random. Then ... 阅读全文
posted @ 2015-03-19 07:16 keepshuatishuati 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Similar to the sorted array. But we have to remember, the position of node not depends on the index. So we need do two more things:1. Ensure the point... 阅读全文
posted @ 2015-03-19 05:48 keepshuatishuati 阅读(131) 评论(0) 推荐(0) 编辑
摘要: It is kind of binary search. Since this is a sorted array, we can treat it as inorder traversal. And we can define the root node for the Tree.So find ... 阅读全文
posted @ 2015-03-19 05:38 keepshuatishuati 阅读(114) 评论(0) 推荐(0) 编辑
摘要: The minimum height controls the volumns. So let two runner at two ends start to scan the array. 1 class Solution { 2 public: 3 int maxArea(vector ... 阅读全文
posted @ 2015-03-19 05:34 keepshuatishuati 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Only different with preorder and postorder is that the root start from the beginning for preorder. 1 /** 2 * Definition for binary tree 3 * struct T... 阅读全文
posted @ 2015-03-19 05:30 keepshuatishuati 阅读(166) 评论(0) 推荐(0) 编辑