Set - TLE
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int getMaximumConsecutive(int[] coins) {\n        // math\n        Arrays.sort(coins);\n        int res = 1;\n        for (int val : coins)\n            if (val > res)\n                break;\n            else\n                res += val;\n        return res;\n    }\n\n    public int getMaximumConsecutive_TLE(int[] coins) {\n        // set, O(N^2)\n        Set<Integer> set = new HashSet<>(List.of(0));\n        for (int newVal : coins)\n            for (int val : set.toArray(new Integer[] {}))\n                set.add(val + newVal);\n        // System.out.println(set);\n        int res = 0;\n        for (int i = 0; i < set.size(); i++, res++)\n            if (!set.contains(i))\n                break;\n        return res;\n    }\n}\n```
['Java']