Code Llama 70B:程序语义理解驱动的开源代码生成范式
2026/6/16 19:56:14
题目地址:链接
思路:遍历时记录最小值,当前值减去历史最小值
functionmaxProfit(prices:number[]):number{letans=0letlastMin=prices[0]for(constpriceofprices){lastMin=Math.min(lastMin,price)ans=Math.max(ans,price-lastMin)}returnans};