当前位置:网站首页>Leecode 122. Zuijia timing of buying and selling stocks ②
Leecode 122. Zuijia timing of buying and selling stocks ②
2022-07-04 03:10:00 【Attacking-Coder】
Vision is limited to the present and the next As long as the stock rises, buy it immediately and then sell it directly , Then look back one space As long as the current is lower than the latter ( Can make money ) Buy and sell immediately This has been making money
var maxProfit = function(prices) {
// Vision is limited to the present and the next As long as the stock rises, buy it immediately and then sell it directly , Then look back one space As long as the current is lower than the latter ( Can make money ) Buy and sell immediately This has been making money
let res = 0
for(let i =1;i<prices.length;i++){
if(prices[i-1]<prices[i]){
res+=prices[i]-prices[i-1]
}
}
return res
};
边栏推荐
- Optimization theory: definition of convex function + generalized convex function
- The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"
- Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
- Love and self-discipline and strive to live a core life
- [UE4] parse JSON string
- 機器學習基礎:用 Lasso 做特征選擇
- Contest3145 - the 37th game of 2021 freshman individual training match_ G: Score
- 1day vulnerability pushback skills practice (3)
- Basé sur... Netcore Development blog Project Starblog - (14) Implementation of theme switching function
- Redis notes (I) Linux installation process of redis
猜你喜欢

Jenkins configures IP address access

Node write API

This function has none of DETERMINISTIC, NO SQL..... (you *might* want to use the less safe log_bin_t

Don't disagree, this is the most powerful "language" of the Internet

SQL injection (1) -- determine whether there are SQL injection vulnerabilities
![[latex] production of complex tables: excel2latex and detail adjustment](/img/39/0d448ddf006eda262de3ed75666354.jpg)
[latex] production of complex tables: excel2latex and detail adjustment

Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé

96% of the collected traffic is prevented by bubble mart of cloud hosting

Network communication basic kit -- IPv4 socket structure

The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused
随机推荐
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
Optimization theory: definition of convex function + generalized convex function
Keep an IT training diary 054- opening and closing
Lichuang EDA learning notes 14: PCB board canvas settings
What are the conditions for the opening of Tiktok live broadcast preview?
3D game modeling is in full swing. Are you still confused about the future?
Basé sur... Netcore Development blog Project Starblog - (14) Implementation of theme switching function
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
Is online futures account opening safe and reliable? Which domestic futures company is better?
在尋求人類智能AI的過程中,Meta將賭注押向了自監督學習
[UE4] parse JSON string
Record a problem that soft deletion fails due to warehouse level error
Enhanced for loop
Key knowledge of embedded driver
Osnabrueck University | overview of specific architectures in the field of reinforcement learning
MySQL workbench use
2022 examination summary of quality controller - Equipment direction - general basis (quality controller) and examination questions and analysis of quality controller - Equipment direction - general b
Experience summary of the 12th Blue Bridge Cup (written for the first time)
Jenkins continuous integration environment construction V (Jenkins common construction triggers)