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.
又是时间复杂度,离真相就差一行代码。。。还是没想出来,,看了discuss才知道答案。
陪我们走过一段别人无法替代的记忆。