https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/564/
Explore - LeetCode
LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.
leetcode.com
javascript
닫기/**
* @param {number[]} prices
* @return {number}
*/
var maxProfit = function (prices) {
return prices.reduce((a, c, i) => {
if (prices.length > i + 1 && 0 < prices[i + 1] - c) {
a += prices[i + 1] - c ;
}
return a;
}, 0);
};
GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드
릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.
github.com
'Coding Test > LeetCode' 카테고리의 다른 글
[LeetCode] (Trees) Lv Easy. Maximum Depth of Binary Tree (0) | 2023.01.21 |
---|---|
[LeetCode] (Linked List) Lv Easy. Delete Node in a Linked List (0) | 2023.01.16 |
[LeetCode] (Strings) Lv Easy. Reverse Integer (0) | 2023.01.16 |
[LeetCode] (Array) Lv Easy. Remove Duplicates from Sorted Array (0) | 2023.01.14 |
[LeetCode] (Array) Lv Easy. Find Target Indices After Sorting Array (0) | 2023.01.12 |
댓글