✅Simple Java Solutions || ✅Runtime 1ms
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```Java\nclass Solution {\n    public int maxProfit(int[] prices) {\n        int buy=Integer.MAX_VALUE,sell=0;\n        for(int i=0;i<prices.length;i++){\n            buy=Math.min(buy,prices[i]);\n            sell=Math.max(sell,prices[i]-buy);\n        }\n       return sell;\n    }\n}\n```\n\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n\n![abcd1.jpeg](https://assets.leetcode.com/users/images/e0d00581-2002-4a1c-bac1-725b4beeabe3_1696764927.6346247.jpeg)\n
['Java']