当前位置:网站首页>Force deduction 121 questions
Force deduction 121 questions
2022-06-13 04:45:00 【Look at the mountains_ Lau】
class Solution
{
public:
int maxProfit(vector<int>& prices)
{
if(prices.empty())
return 0;
// Direct use of a loop , Find the lowest price to buy , And find the maximum profit under this buying price
int profit = 0;
int min = prices[0];
for(int i = 1; i < prices.size(); i++)
{
if(min > prices[i])
min = prices[i];
else
profit = max(profit, prices[i] - min);
}
return profit;
}
};
边栏推荐
- 推荐的图片临时在线压缩工具
- 2022氯化工艺操作证考试题库及模拟考试
- Li Kou brush question 647 Palindrome substring
- SEO specification
- Red Treasure Book Reading Notes (continuously updated)
- Read paper 20 together: spatiotemporal prediction of PM2.5 concentration by idw-blstm under different time granularity
- Flutter dart variables and constants
- Ctfshow SQL injection (231-253)
- Construction problem of D Xiaohong
- CTFSHOW SQL注入篇(231-253)
猜你喜欢

【Try to Hack】upload-labs通关(暂时写到12关)

How to use redis

Redis主从复制、哨兵模式、集群

【JS解决】leedcode 117. 填充每个节点的下一个右侧节点指针 II

Design system based on MVC using javeswingjdbc

Several methods of identifying equivalent circuit of circuit drawing

Advantages of win8.1 and win10
![[JS solution] leedcode 200 Number of islands](/img/c1/bcdb3fc079c634a9a1b3d0fc264987.png)
[JS solution] leedcode 200 Number of islands

【JS解决】leedcode 200. 岛屿数量

Explain the differences and usage scenarios between created and mounted
随机推荐
Blockly learning ----2 Code generation, grid, scaling, events, storage
CTFSHOW SQL注入篇(211-230)
是“凯撒密码”呀。(*‘▽‘*)*
Ionic Cordova command line
D 小红的构造题
PowerShell:因为在此系统上禁止运行脚本,解决方法
Go/golang connection to database
Tita performance treasure: remote one-on-one discussion
Express framework knowledge - Art template template, cookie, session
Use service worker to preferentially request resources - continuous update
【Try to Hack】upload-labs通关(暂时写到12关)
C#获取WebService接口的所有可调用方法[WebMethod]
【JS解决】leedcode 200. 岛屿数量
josephus problem
Autumn wind, dust, youth
SQL notes
On switch() case statement in C language
php开发14 友情链接模块的编写
JS, how to add grid style
2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets