We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e98b10 commit 348c154Copy full SHA for 348c154
best-time-to-buy-and-sell-stock/GUMUNYEONG.js
@@ -0,0 +1,17 @@
1
+/**
2
+ * @param {number[]} prices
3
+ * @return {number}
4
+ */
5
+var maxProfit = function (prices) {
6
+ let max = 0;
7
+
8
+ for (let i = 1; i <= prices.length; i++) {
9
+ for (let j = i + 1; j <= prices.length; j++) {
10
+ const profit = prices[j] - prices[i];
11
+ max = profit > max ? profit : max;
12
+ }
13
14
15
+ return max;
16
+};
17
0 commit comments