当前位置:网站首页>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;
}
};
边栏推荐
- 小C的记事本
- Nodejs parsing get request URL string
- Sword finger offer 56 - I. number of occurrences in the array
- Solution to sudden font change in word document editing
- [JS solution] leedcode 117 Populate the next right node pointer II for each node
- Redis master-slave replication, sentinel mode, cluster
- Third party comment plugin
- Returns the width and height of an element
- General communication protocol for industrial Internet
- PHP security development 15 user password modification module
猜你喜欢
Redis master-slave replication, sentinel mode, cluster
【JS解决】leedcode 117. 填充每个节点的下一个右侧节点指针 II
[try to hack] upload labs (temporarily write to 12)
2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
[leetcode]- binary search
用navicat将mysql数据转化为postgresql
【Flutter 问题系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 弹窗中不能二次跳转路由问题的解决方案
The differences between the four startup modes of activity and the applicable scenarios and the setting methods of the two startup modes
2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
C # get all callable methods of WebService interface [webmethod]
随机推荐
Go/golang connection to database
Flutter dart variables and constants
Explain the differences and usage scenarios between created and mounted
CTFSHOW SQL注入篇(211-230)
Crawler scrapy framework learning 2
Conception d'un système basé sur MVC avec javaswing JDBC
C # get all callable methods of WebService interface [webmethod]
It's the Caesar code. (*‘▽‘*)*
Internet people a few years ago vs Internet people today
工业互联网通用通信协议
Express framework knowledge - Art template template, cookie, session
Ctfshow SQL injection (231-253)
Converting MySQL data to PostgreSQL with Navicat
Handwritten promise and its method, with detailed notes
Applet - uniapp realizes the functions of two-dimensional code picture pop-up and picture saving
Blockly learning ----2 Code generation, grid, scaling, events, storage
Cesium:CesiumLab制作影像切片与切片加载
The problem that ionic3 cannot automatically install the APK package
Explain the role of key attribute in V-for
Promise processing JS multithreads get the same processing result after all the results are obtained