typescript solution
\nfunction maxProfit(prices: number[]): number {\n  let min = prices[0]\n  let max = 0\n  \n  for (let i = 1; i < prices.length; i++) {\n    min = Math.min(min,
```\nfunction maxProfit(prices: number[]): number {\n  let min = prices[0]\n  let max = 0\n  \n  for (let i = 1; i < prices.length; i++) {\n    min = Math.min(min, prices[i])\n    max = Math.max(max, prices[i] - min)\n  }\n  \n  return max\n}\n```
['Dynamic Programming', 'TypeScript', 'JavaScript']