From fac09084cb9c08edf287ee24f29d193f7e29fb60 Mon Sep 17 00:00:00 2001 From: piyush6348 Date: Sat, 3 Oct 2020 21:33:20 +0530 Subject: [PATCH] added Buy & Sell stock 1 --- Arrays/Buy And Sell Stocks 1.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Arrays/Buy And Sell Stocks 1.cpp diff --git a/Arrays/Buy And Sell Stocks 1.cpp b/Arrays/Buy And Sell Stocks 1.cpp new file mode 100644 index 0000000..fbfa41d --- /dev/null +++ b/Arrays/Buy And Sell Stocks 1.cpp @@ -0,0 +1,13 @@ +int maxProfit(vector& prices) { + int n = prices.size(); + if(n == 0 || n == 1) + return 0; + int mini = prices[0]; + int ans = 0; + for(int i = 1;i