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

Commit150fcd4

Browse files
committed
update: 121
1 parentbe10ef0 commit150fcd4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
4545
|91|[Decode Ways](https://leetcode.com/problems/decode-ways/)|[JavaScript](./src/decode-ways/res.js)|Medium|
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|
48+
|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|
4849
|127|[Word Ladder](https://leetcode.com/problems/word-ladder/)|[JavaScript](./src/word-ladder/res.js)|Medium|
4950
|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions/)|[JavaScript](./src/surrounded-regions/res.js)|Medium|
5051
|133|[Clone Graph](https://leetcode.com/problems/clone-graph/)|[JavaScript](./src/clone-graph/res.js)|Medium|
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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(min>element){
13+
min=element;
14+
max=-1;
15+
}elseif(max<element){
16+
max=element;
17+
}
18+
19+
if(min!==999999&&max!==-1){
20+
res=Math.max(res,max-min);
21+
}
22+
}
23+
24+
returnres;
25+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp