[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"searchBlogPosts":3,"$fES4PqIGwuBH96NxQZcTgkFsgDnzRD80UoTTrA9ifQok":7},[4],{"_path":5,"title":6},"\u002Fblog\u002F2023\u002F09\u002F17\u002Fspring-boot-postgresql","Spring Boot with PostgreSQL & pgAdmin in Docker",{"title":8,"category":9,"problemHtml":10,"solutions":11,"repoUrl":20},"Buy And Sell Crypto","Data Structures & Algorithms","",[12,16],{"lang":13,"label":14,"html":15},"java","Java","\u003Cpre>\u003Ccode class=\"language-java\">class Solution {\n    public int maxProfit(int[] prices) {\n        int maxProfit = 0;\n\n        for (int fast = 1, slow = 0; fast &lt; prices.length; fast++) {\n            int profit = prices[fast] - prices[slow];\n\n            maxProfit = Math.max(maxProfit, profit);\n\n            if (prices[fast] &lt; prices[slow]) {\n                slow = fast;\n            }\n        }\n\n        return maxProfit;\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>",{"lang":17,"label":18,"html":19},"python","Python","\u003Cpre>\u003Ccode class=\"language-python\">class Solution:\n    def maxProfit(self, prices: List[int]) -&gt; int:\n\n        maxProfitTrade, slow = 0, prices[0]\n\n        for price in prices:\n            profit = price - slow\n\n            maxProfitTrade = max(maxProfitTrade, profit)\n            slow = min(slow, price)\n\n        return maxProfitTrade\u003C\u002Fcode>\u003C\u002Fpre>","https:\u002F\u002Fgithub.com\u002Fvishwarajsali\u002FInterviewPrep\u002Ftree\u002Fmain\u002FData%20Structures%20%26%20Algorithms%2Fbuy-and-sell-crypto"]