当前位置:网站首页>A wonderful time to buy and sell stocks
A wonderful time to buy and sell stocks
2022-07-01 18:34:00 【Free dreamer】

Traverse the entire array , Deviate to No i Number of hours , Before finding out i-1 The minimum number , Subtracting , Update stock profits
step
1. Create two variables , One stores stock profits , Before a storage i-1 The minimum value of
2. Traverse the entire array for comparison
class Solution {
public:
int maxProfit(vector<int>& prices) {
int res = 0,m=1e4+10;
for(int i = 0;i < prices.size(); i++){
res=max(prices[i]-m,res);
m=min(m,prices[i]);
}
return res;
}
};边栏推荐
- SCP -i private key usage
- When the fixed frequency artifact falls in love with multithreading | ros2 fixed frequency topic release demo
- Localization through custom services in the shuttle application
- Vue uses keep alive to cache page optimization projects
- Cassette helicopter and alternating electric field magnetic manometer DPC
- Data query language (DQL)
- Rotation order and universal lock of unity panel
- This is the latest opportunity of the London bank trend
- How to retrieve the password for opening Excel files
- L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
猜你喜欢

. Net cloud native architect training camp (permission system code implements actionaccess) -- learning notes
![Htt [ripro network disk link detection plug-in] currently supports four common network disks](/img/e4/c06b94243cdbe391b8b2124ff30789.jpg)
Htt [ripro network disk link detection plug-in] currently supports four common network disks

主成分计算权重

Review Net 20th anniversary development and 51aspx growth

Yolov5 practice: teach object detection by hand

Penetration practice vulnhub range Tornado

Localization through custom services in the shuttle application

必看,时间序列分析

Flex layout

LeetCode 148. Sort linked list
随机推荐
Penetration practice vulnhub range Nemesis
Redis主从实现10秒检查与恢复
Blue Bridge Cup real problem: word analysis
Develop those things: add playback address authentication to easycvr platform
Localization through custom services in the shuttle application
Bernoulli distribution (a discrete distribution)
Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
APK签名流程介绍[通俗易懂]
Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?
D. Yet Another Minimization Problem
How to retrieve the password for opening Excel files
Length of learning and changing
Setting up a time server requires the client to automatically synchronize the time of the server at 9 a.m. every day
Database - MySQL advanced SQL statement (I)
Irradiance, Joule energy, exercise habits
Session layer of csframework, server and client (1)
[CF559E]Gerald and Path
Opencv map reading test -- error resolution
Batch export all pictures in PPT in one second
Review Net 20th anniversary development and 51aspx growth