C++ solutions
\nclass Solution {\npublic:\n    int maxProfit(vector<int>& prices) {\n        int profit=0;\n        int minelem=prices[0];\n        for(int i=1;i<prices.size(
```\nclass Solution {\npublic:\n    int maxProfit(vector<int>& prices) {\n        int profit=0;\n        int minelem=prices[0];\n        for(int i=1;i<prices.size();i++){\n           minelem=min(prices[i],minelem);\n            profit=max(profit,(prices[i]-minelem));\n        }\n        return profit;\n    }\n};\n```
['C', 'C++']