From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/buy_sell_stock_fee.cpp | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 other/buy_sell_stock_fee.cpp (limited to 'other/buy_sell_stock_fee.cpp') diff --git a/other/buy_sell_stock_fee.cpp b/other/buy_sell_stock_fee.cpp deleted file mode 100644 index 0375c56..0000000 --- a/other/buy_sell_stock_fee.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// 714. Best Time to Buy and Sell Stock with Transaction Fee -#include "leetcode.h" - -/* - * given an array 'prices' where 'prices[i]' is the price of a given stock on - * the i'th day, and an integer 'fee' representing a transaction fee. find the - * maximum profit you can achieve. you may complete as many transactions as youl - * like, but you need to pay the transaction fee for each transaction. note: you - * may not engage in multiple transactions simultaneously (ie. you must sell the - * stock before you buy again) - */ - -class Solution { -public: - int maxProfit(vector &prices, int fee) { - int n = prices.size(); - if (n < 2) - return 0; - vector hold(n, 0), sold(n, 0); - hold[0] = -prices[0]; - for (int i = 1; i < n; i++) { - hold[i] = max(hold[i - 1], sold[i - 1] - prices[i]); - sold[i] = max(sold[i - 1], hold[i - 1] - fee + prices[i]); - } - return sold[n - 1]; - } -}; - -int main() { - Solution obj; - vector p1 = {1, 3, 2, 8, 4, 9}; - vector p2 = {1, 3, 7, 5, 10, 3}; - printf("%d\n", obj.maxProfit(p1, 2)); // expect: 8 - printf("%d\n", obj.maxProfit(p2, 3)); // expect: 6 -} -- cgit v1.2.3