beats 100 in performance
Intuition\n Describe your first thoughts on how to solve this problem. \nSuppose we have a list starting from 0 to n :\n[ 0, 1, 2, ...., n ]\nIf you add a numbe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSuppose we have a list starting from 0 to n :\n[ 0, 1, 2, ...., n ]\nIf you add a number m to all elements in the list, you\'ll have a new list like this :\n[ m, m+1, m+2, ...., n+m]\nJoin the two lists and you\'ll have :\n[ 0, 1, 2, ...., n, m, m+1, m+2, ...., m+n]\n\nFor the list to be valid as prescripred in the description we need : 1 <= m <= n+1\nAt the lowest range we will have without duplicates: \n[ 0, 1, 2, ...., n, n+1]\nAt the highest range we will have without duplicates:\n[ 0, 1, 2, ...., n, n+1, n+2, ...., n+m]\n# Approach\n<!-- Describe your approach to solving the problem. -->\nyou keep iterating over the array, adding the values which are less or equal to the next val, and then making them negative so you don\'t add them again in the next iteration, if in the real case you don\'t want to modify the coins array, you would have to either create a copy or revert the negative values. \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n) but not really since you keep iterating over the array until there is no more change in the next val, performs better than if you sort the array. \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nint getMaximumConsecutive(int* coins, int coinsSize) {\n    int next = 1, current =0;\n    while(next != current){\n        current = next;\n        for(int i = 0 ; i < coinsSize ; i++){\n            if( coins[i] > 0 && coins[i] <= next ){\n                next += coins[i];\n                coins[i] *= -1;\n            }\n        }\n    }\n    return next;\n}\n```
['C']