c++ solutions using Kadane's algorithm
smjh\n\nint maxProfit(vector<int>& prices) {\n        int n= prices.size();\n        int maxprofit = 0;\n        int minvalue = INT_MAX;\n        for(int i =0;i
smjh\n```\nint maxProfit(vector<int>& prices) {\n        int n= prices.size();\n        int maxprofit = 0;\n        int minvalue = INT_MAX;\n        for(int i =0;i<n;i++){\n            minvalue = min(prices[i],minvalue);\n            maxprofit= max(maxprofit,prices[i] - minvalue);\n        }\n        return maxprofit;\n    }\n```\nDo upvote if you find it helpful
['C']