摘要: https://blog.csdn.net/a745233700/article/details/80977133 https://blog.csdn.net/a745233700/article/details/80959716 阅读全文
posted @ 2020-05-13 15:20 弓呆的胖次 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 思路:可以把交易日分为上涨交易日与下降交易日,假如今天比昨天贵,就叫上涨。用贪心策略,每个上涨交易日都买,下降交易日都不买 class Solution {//贪心策略,所有上涨交易日都买,所有下降交易日都不卖 public int maxProfit(int[] prices) { int len 阅读全文
posted @ 2020-05-13 10:57 弓呆的胖次 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 思路:可以找出数组里每一个元素右侧的最大值,再遍历整个数组,找当前元素右侧最大值和当前元素数值的差,最大的就是要求的结果。 class Solution { public int maxProfit(int[] prices) { int[] rightMax=new int[prices.leng 阅读全文
posted @ 2020-05-13 10:07 弓呆的胖次 阅读(147) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/triangle/solution/zi-di-xiang-shang-dong-tai-gui-hua-lei-si-yu-cong-/ 思路: 以[[2],[3,4],[6,5,7],[4,1,8,3]]为例: 假设从倒数第二列开 阅读全文
posted @ 2020-05-13 09:20 弓呆的胖次 阅读(216) 评论(0) 推荐(0) 编辑