摘要:
"123. 买卖股票的最佳时机 III" 暴力做法 直接枚举中间值,分成两个 "121. 买卖股票的最佳时机" 题做: class Solution { public int maxProfitOne(int[] prices) { int min = Integer.MAX_VALUE; int 阅读全文
摘要:
"121. 买卖股票的最佳时机" 动态规划:前i天的最大收益 = max{前i 1天的最大收益,第i天的价格 前i 1天中的最小价格} 维护两个值即可:min,ans class Solution { public int maxProfit(int[] prices) { int min = In 阅读全文
摘要:
"120. 三角形最小路径和" 动态规划入门题 class Solution { public int minimumTotal(List triangle) { if (triangle.get(0).size() == 0) return 0; int[][] f = new int[trian 阅读全文