✅Fast JAVA Solution
JAVA Code\nJAVA []\nclass Solution {\n    public int maxProfit(int[] prices) {\n        int lsf = Integer.MAX_VALUE;\n        int op = 0;\n        int pist = 0;
# JAVA Code\n``` JAVA []\nclass Solution {\n    public int maxProfit(int[] prices) {\n        int lsf = Integer.MAX_VALUE;\n        int op = 0;\n        int pist = 0;\n        \n        for(int i = 0; i < prices.length; i++){\n            if(prices[i] < lsf){\n                lsf = prices[i];\n            }\n            pist = prices[i] - lsf;\n            if(op < pist){\n                op = pist;\n            }\n        }\n        return op;\n    }\n}\n```\n\n![kitty.jpeg](https://assets.leetcode.com/users/images/6233d50d-1433-4516-8d8e-90fb8e13d32f_1677303191.974716.jpeg)\n
['Java']