摘要: Well, this problem desires for the use of dynamic programming. They key to any DP problem is to come up with the state equation. In this problem, we d... 阅读全文
posted @ 2015-06-03 11:54 jianchao-li 阅读(3676) 评论(0) 推荐(0) 编辑
摘要: Recursive (Backtracking)This is a typical problem that can be tackled by backtracking.Since backtracking has a more-or-less similar template, so I do ... 阅读全文
posted @ 2015-06-03 00:19 jianchao-li 阅读(218) 评论(0) 推荐(0) 编辑
摘要: This problem is similar toBest Time to Buy and Sell Stock. Givenprices, we find the day (denoted asbuy) of the first local minimum and the day (denote... 阅读全文
posted @ 2015-06-03 00:16 jianchao-li 阅读(179) 评论(0) 推荐(0) 编辑
摘要: This post shares a very simple solution, whose code is rewritten below, just 5 lines :-) 1 class Solution { 2 public: 3 int maxProfit(vector& pric... 阅读全文
posted @ 2015-06-03 00:14 jianchao-li 阅读(145) 评论(0) 推荐(0) 编辑