diff --git a/solution/0041.First Missing Positive/Solution.c b/solution/0041.First Missing Positive/Solution.c new file mode 100644 index 0000000000000..6e859a40cb28e --- /dev/null +++ b/solution/0041.First Missing Positive/Solution.c @@ -0,0 +1,22 @@ +int firstMissingPositive(int* nums, int numsSize) { + + int Max = nums[0], i, *Count; + + for(i = 1; i 0){ + Count[nums[i]]++; + } + } + + i = 1; + while(Count[i] != 0){ + i++; + } + + return i; +} diff --git a/solution/0066.Plus One/Solution.py b/solution/0066.Plus One/Solution.py new file mode 100644 index 0000000000000..9af96eca520b8 --- /dev/null +++ b/solution/0066.Plus One/Solution.py @@ -0,0 +1,20 @@ +class Solution: + def plusOne(self, digits): + """ + :type digits: List[int] + :rtype: List[int] + """ + + i = len(digits)-1 + digits[i] += 1 + + while i > 0 and digits[i] > 9 : + digits[i] = 0 + i -= 1 + digits[i] += 1 + + if digits[0] > 9: + digits[0] = 0 + digits.insert(0, 1) + + return digits diff --git a/solution/0066.Plus One/Solution2.py b/solution/0066.Plus One/Solution2.py new file mode 100644 index 0000000000000..765de08c522b6 --- /dev/null +++ b/solution/0066.Plus One/Solution2.py @@ -0,0 +1,8 @@ +class Solution: + def plusOne(self, digits): + """ + :type digits: List[int] + :rtype: List[int] + """ + + return list(map(int, str(int("".join(map(str, digits)))+1)))