diff --git a/C++/Best Time to Buy and Sell Stock b/C++/Best Time to Buy and Sell Stock new file mode 100644 index 00000000..e9a4d20c --- /dev/null +++ b/C++/Best Time to Buy and Sell Stock @@ -0,0 +1,19 @@ +class Solution { +public: +int diff=0; + int minElement=INT_MAX; + int maxProfit(vector& prices) { + for(int i=0;iminElement){ + diff=max(diff,prices[i]-minElement); + } + if(prices[i]