![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d7c2c89351acf6d7cda5b7ac7a68db7a.webp?x-image-process=image/format,png#pic_center)
最强解析面试题:best-time-to-buy-and-sell-stock
文章讲解 “ best-time-to-buy-and-sell-stock ” 经典面试题,包含思路及源码,及解惑!
题目
Say you have an array for which the i th element
is the price of a given stock on day i.
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.
中文描述:
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。
如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算