C++|Simple O(N)| ONE_PASS
Intuition\n Describe your first thoughts on how to solve this problem. \nSimply track mininum upto each element take the differnee and comapre it it is greater 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimply track mininum upto each element take the differnee and comapre it it is greater than previous then update .\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nJust traverse the whole array and track minimum so far and take take its diffrence with each element and keep updating the max diff.At lst return the maximum diffrence.\n# Complexity\n- Time complexity:$$O(N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProfit(vector<int>& arr) {\n        int ans=0;\n        int n=arr.size();\n        int mini=INT_MAX,maxi=0;\n         for(int i=0;i<n;i++){\n             ans=max(ans,arr[i]-mini);\n             mini=min(arr[i],mini);\n           //  maxi=max(arr[i+1],maxi);\n         }\n         return ans;\n    }\n};\n```
['Array', 'C++']