From cfa04cd78cdd22c8b1c757b5302a44f642d70327 Mon Sep 17 00:00:00 2001 From: Prashant Gehlot <98162883+prashant-gehlot@users.noreply.github.com> Date: Sat, 8 Oct 2022 09:37:07 +0530 Subject: [PATCH] Create best_time_to_buy_and_sell_stock.cpp --- best_time_to_buy_and_sell_stock.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 best_time_to_buy_and_sell_stock.cpp diff --git a/best_time_to_buy_and_sell_stock.cpp b/best_time_to_buy_and_sell_stock.cpp new file mode 100644 index 0000000..fc5f588 --- /dev/null +++ b/best_time_to_buy_and_sell_stock.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + int maxProfit(vector& prices) { + int maxPro = 0; + int minPrice = INT_MAX; + for(int i=0; i