2014年1月18日

LeetCode: Best Time to Buy and Sell Stock I & II & III

摘要: Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.最开始nc,只想到了brute force算法。想着最大减最小就是结果,但是如果最大值出现在最小值之前就不能算了。所以 阅读全文

posted @ 2014-01-18 23:58 longhorn 阅读(211) 评论(0) 推荐(0) 编辑

导航