Java Simple Explanation (beats 99)
\nclass Solution {\n    public int getMaximumConsecutive(int[] c) {\n        Arrays.sort(c);\n        int n = c.length;\n        int sum = 1;\n        for(int i
```\nclass Solution {\n    public int getMaximumConsecutive(int[] c) {\n        Arrays.sort(c);\n        int n = c.length;\n        int sum = 1;\n        for(int i=0;i<n;i++){\n            if(c[i]<=sum) sum=sum+c[i];\n            else break;\n        }\n        return sum;\n        \n        \n    }\n}\n```\n\nYou want to get the value of the biggest sum you can make using consecutive integers and these integers should be from the array.\n\nLet us say,\ncurrently,\nthe consecutive sum I want is stored in \'sum\'.\n(initialised as sum=1)\nNow\nif my current coin is equal to sum,\nthen I am done! (Because I was looking for that sum value and a coin serves it)\n\nif my current coing is smaller than sum,\nthen that means I can pick the largest sum (which is sum itself) and add my coin value to it, to extend my reach of the sum.\n\nIf your current sum is say 6 and then coin you got is y, then you can extend your range! Why? Because 1,2,3...,y,...6 are already there. You add your y to all these numbers and the max reach is 6+y, that is your new sum. You are able to form all the sums between 6 to 6+y now.\nIf you cannot, extend the range, then that is the maximum you could have gone...\n\n\n\n\n
[]