Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdcdb766

Browse files
committed
update: 122
1 parent150fcd4 commitdcdb766

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
4646
|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/)|[JavaScript](./src/restore-ip-addresses/res.js)|Medium|
4747
|120|[Triangle](https://leetcode.com/problems/triangle/)|[JavaScript](./src/triangle/res.js)|Medium|
4848
|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)|[JavaScript](./src/best-time-to-buy-and-sell-stock/res.js)|Easy|
49+
|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)|[JavaScript](./src/best-time-to-buy-and-sell-stock-ii/res.js)|Easy|
4950
|127|[Word Ladder](https://leetcode.com/problems/word-ladder/)|[JavaScript](./src/word-ladder/res.js)|Medium|
5051
|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions/)|[JavaScript](./src/surrounded-regions/res.js)|Medium|
5152
|133|[Clone Graph](https://leetcode.com/problems/clone-graph/)|[JavaScript](./src/clone-graph/res.js)|Medium|
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
*@param {number[]} prices
3+
*@return {number}
4+
*/
5+
varmaxProfit=function(prices){
6+
letmin=999999,max=-1;
7+
letres=0;
8+
9+
for(letindex=0;index<prices.length;index++){
10+
constelement=prices[index];
11+
12+
if(index===0||element<max||min>element){
13+
if(min!==999999&&max!==-1){
14+
res+=(max-min);
15+
}
16+
17+
min=element;
18+
max=-1;
19+
}elseif(max<element){
20+
max=element;
21+
}
22+
}
23+
24+
if(min!==999999&&max!==-1){
25+
res+=(max-min);
26+
}
27+
28+
returnres;
29+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp