diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/best_buy_sell_stock.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/best_buy_sell_stock.cpp')
-rw-r--r-- | other/best_buy_sell_stock.cpp | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/other/best_buy_sell_stock.cpp b/other/best_buy_sell_stock.cpp deleted file mode 100644 index 31b2a17..0000000 --- a/other/best_buy_sell_stock.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// 121. Best Time to Buy and Sell Stock -#include "leetcode.h" - -/* - * given an array 'prices' where 'prices[i]' is the price of a given stock on - * the ith day. maximise profit by choosing a single day to buy one stock and - * choosing a diff day in future to sell stock. return maximum profit achievable - * from transaction. - */ - -class Solution { -public: - int maxProfit(vector<int> &prices) { - int lsf = INT_MAX, op = 0, pist = 0; - for (int i = 0; i < prices.size(); i++) { - if (prices[i] < lsf) - lsf = prices[i]; - pist = prices[i] - lsf; - if (op < pist) - op = pist; - } - return op; - } -}; - -int main() { - Solution obj; - vector<int> p1 = {7, 1, 5, 3, 6, 4}, p2 = {7, 6, 4, 3, 1}; - cout << obj.maxProfit(p1) << endl; // expect: 5 - cout << obj.maxProfit(p2) << endl; // expect: 0 -} |