From 38ca2e35fb7c4b05d4b8a1a443bc01ad1b5fc0c3 Mon Sep 17 00:00:00 2001 From: Dhwanit Chauhan <31712631+dhwanit13@users.noreply.github.com> Date: Mon, 8 Oct 2018 18:27:10 +0530 Subject: [PATCH] Buy and Sell Stock --- Buy and Sell Stock/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Buy and Sell Stock/README.md diff --git a/Buy and Sell Stock/README.md b/Buy and Sell Stock/README.md new file mode 100644 index 0000000..b21172f --- /dev/null +++ b/Buy and Sell Stock/README.md @@ -0,0 +1,29 @@ +``` +class Solution { +public: + int maxProfit(vector& prices) { + + int i, j, k, min = INT_MAX; + int max = 0; + k = prices.size(); + if(k==0) + { + return 0; + } + int sum; + for(i=0; imax) + { + max = prices[i]-min; + } + } + + return max; + } +}; +```