diff --git a/best-time-to-buy-and-sell-stock/limlimjo.js b/best-time-to-buy-and-sell-stock/limlimjo.js new file mode 100644 index 000000000..47a995bad --- /dev/null +++ b/best-time-to-buy-and-sell-stock/limlimjo.js @@ -0,0 +1,24 @@ +/** + * @param {number[]} prices + * @return {number} + */ +var maxProfit = function(prices) { + + // 최대 수익 + let maxProfit = 0; + // prices 배열의 0번째를 최소 가격으로 시작 + let minPrice = prices[0]; + + // prices 배열 for문 돌려서 최대 수익 찾기 + for(let i=0; i