Brother of Best Time to Buy and Sell Stocks
Intuition and Approach:-\n\nThis is exactly the Best time to buy and sell stocks problem. Here\'s the solution to that problem- https://leetcode.com/problems/be
**Intuition and Approach:-**\n\nThis is exactly the ```Best time to buy and sell stocks``` problem. Here\'s the solution to that problem- https://leetcode.com/problems/best-time-to-buy-and-sell-stock/discuss/2140907/my-concise-java-on-solution\nHere, we only have to initiate max as -1, in case of a decreasing array.\n\n**Code:-**\n\n```\n    public int maximumDifference(int[] nums) \n    {\n        int max=-1,lastindex=0;\n        for (int i = 1; i < nums.length; i++)\n        {\n            if (nums[i]>nums[lastindex])\n                max=Math.max(max,nums[i]-nums[lastindex]);\n            else\n                lastindex=i;\n        }\n        return max;\n    }\n```\t
['Array', 'Java']