✅Easy C++ solution in few line of code!
If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistake please let me know. Thank you!\u27
> **If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistake please let me know. Thank you!\u2764\uFE0F**\n> \n\n---\n\n## Explanation:\n\n### Solution 01\n\n- The idea is quite simple, we\u2019ve to find the max profit by selling the stocks.\n- We took 2 int variables: **mn** *(to store the minimum till a particular date)* **& ans.**\n- Run a for loop and in every time check for the minimum value till that iteration and store it in mn ~**min(mn, prices[i])**.\n- Also, find the ans with **max(ans, prices[i]-mn)**.\n- **Time complexity:** O(n).\n\n---\n\n## Solution:\n\n```cpp\n//Solution 01:\nclass Solution {\npublic:\n    int maxProfit(vector<int>& prices) {\n        int n= prices.size();\n        int mn= INT_MAX;\n        int ans=0;\n        \n        for(int i=0; i<n; i++){\n            mn = min(mn, prices[i]);\n            ans = max(ans, prices[i]-mn);\n        }\n        \n        return ans;\n    }\n};\n```\n\n---\n\n> **Please upvote this solution**\n>
['C', 'C++']