摘要: #include <iostream> 阅读全文
posted @ 2019-10-23 21:12 pycodego 阅读(118) 评论(0) 推荐(0) 编辑
摘要: class Solution { private: int in=0; int sum=0; //保留最大的利润值 public: int maxProfit(vector& prices) { in=prices[0]; for(int i=0;iin) sum=Max(sum,prices[i]-in); else if... 阅读全文
posted @ 2019-10-23 19:46 pycodego 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 一般的求数组中连续的最大,最小值时,通常的解法思路就是------>一直往前,当其不满足某个条件时就直接在这截止,再重新以当前位置为起点再出发class Solution { public int maxSubArray(int[] nums) { int ans = nums[0]; int sum = 0; for(int num: n... 阅读全文
posted @ 2019-10-23 12:00 pycodego 阅读(164) 评论(0) 推荐(0) 编辑