自己已经意识到就是在输入数组里找递增子序列,但还是没想通。上网找点提示,参考了LeetCode – Best Time to Buy and Sell Stock II (Java),看了人家的,恍然大悟,不难,但就是想不到。
这系列 Best Time to Buy and Sell Stock
的题看来也是比较经典的
- 121. Best Time to Buy and Sell Stock
- 122. Best Time to Buy and Sell Stock II
- 123. Best Time to Buy and Sell Stock III
- 188. Best Time to Buy and Sell Stock IV
- 309. Best Time to Buy and Sell Stock with Cooldown
- 714. Best Time to Buy and Sell Stock with Transaction Fee
Java
1 | class Solution { |
Submission Detail
- 201 / 201 test cases passed.
- Your runtime beats 99.86 % of java submissions.
JavaScript
1 | /** |
Submission Detail
- 201 / 201 test cases passed.
- Your runtime beats 18.88 % of javascript submissions.