JAVASCRIPT 99,99% BEATS
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<O(n)>\n\n- Space complexity:\n<O(1)>\n\n# Code\n```\n/**\n * @param {number[]} prices\n * @return {number}\n */\nvar maxProfit = function(prices) {\n    let maxProfit = 0;\n    let minPrice = prices[0];\n    for (let i = 1; i < prices.length; i++) {\n        const currentPrice = prices[i];\n        const currentProfit = currentPrice - minPrice;\n        if (currentProfit > maxProfit) {\n            maxProfit = currentProfit;\n        }\n        if (currentPrice < minPrice) {\n            minPrice = currentPrice;\n        }\n    }\n    return maxProfit;\n};\n\n```
['JavaScript']