Java - Fastest Greedy Solution, 100%
Greedy\n\n\nclass Solution {\n    public int maxProfit(int[] prices) {\n        \n        int max=0,min=prices[0];\n        for(int i=1;i<prices.length;i++)   {
Greedy\n\n````\nclass Solution {\n    public int maxProfit(int[] prices) {\n        \n        int max=0,min=prices[0];\n        for(int i=1;i<prices.length;i++)   {\n\t\t\n            if(min<prices[i])\n                max=Math.max(prices[i]-min,max);\n            else\n                min=prices[i];\n        }\n        return max;\n    }\n}\n````\n\nKadane\'s Algorithm\n````\nclass Solution {\n    public int maxProfit(int[] prices) {\n        \n        int max=0, sum=0;\n        for(int i=0;i<prices.length-1;i++)\n        {\n            sum = Math.max(sum+prices[i+1]-prices[i],0);\n            max = Math.max(sum, max);\n        }\n        return max;\n    }\n}\n````\n\nIf it helped you then I will be happy if you give a **upvote**!
['Greedy', 'Java']