Skip to content

Commit

Permalink
이슈 #445에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 5, 2024
1 parent 9972c0a commit ff40e7f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions LeetCode/Best_Time_to_Buy_and_Sell_Stock_II.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public:
int maxProfit(vector<int>& prices) {
int profit = 0;

for (int i = 1; i < prices.size(); i++) {
if (prices[i] > prices[i - 1]) {
profit += prices[i] - prices[i - 1];
}
}

return profit;
}
};

0 comments on commit ff40e7f

Please sign in to comment.