Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fa10d46

Browse files
committed
22w4: add 121 js solution
1 parent 2f11fff commit fa10d46

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum/)| |Hard|
322322
|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/)| |Hard|
323323
|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)| [js](./algorithms/bestTimeToBuyAndSellStockIi/Solution.js) |Medium|
324-
|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)| [java](./algorithms/bestTimeToBuyAndSellStock/Solution.java) |Medium|
324+
|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)| [java](./algorithms/bestTimeToBuyAndSellStock/Solution.java), [js](./algorithms/bestTimeToBuyAndSellStock/Solution.js) |Medium|
325325
|120|[Triangle](https://leetcode.com/problems/triangle/)| |Medium|
326326
|119|[Pascal's Triangle II](https://leetcode.com/problems/pascals-triangle-ii/)| |Easy|
327327
|118|[Pascal's Triangle](https://leetcode.com/problems/pascals-triangle/)| |Easy|
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var maxProfit = function(prices) {
2+
let min = prices[0];
3+
let max = 0;
4+
for (let price of prices) {
5+
max = Math.max(max, price - min);
6+
min = Math.min(price, min);
7+
}
8+
return max;
9+
};

0 commit comments

Comments
 (0)