题解 | #买卖股票的最好时机(一)#

买卖股票的最好时机(一)

http://www.nowcoder.com/practice/64b4262d4e6d4f6181cd45446a5821ec

//动态规划思路

public class Solution { /** * * @param prices int整型一维数组 * @return int整型 */ public int maxProfit (int[] prices) { // write code here int maxProfit = 0; int start = 0; int end = 1; while(end < prices.length){ //如果end位置的值-start位置的值小于0,start = end,否则将end处卖出的值与maxProfit比较 if(prices[end] - prices[start] < 0){ start = end; } maxProfit = prices[end] - prices[start] > maxProfit? prices[end] - prices[start]: maxProfit; end++; } return maxProfit; } }

全部评论

相关推荐

合适才能收到offe...:项目岗是什么岗?我看你有段好像跟策划运营相关,如果找运营的话第三段经历写详细点儿。 个人建议是把自我评价删了换成专业技能放在工作经验上或者下面。学生会那个也可以删,把第一个包装成店铺运营,写4-6给点。第三个也是写4-6个点。注意工作内容➕部分数据。 投递的时候BOS招呼用语改一下,换成我有xx工作经验,熟练掌握xx技能样式,也可以简历截图然后直接发送。
点赞 评论 收藏
分享
2025-12-05 18:09
已编辑
广东药科大学 后端工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务