Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions solution/0041.First Missing Positive/Solution.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
int firstMissingPositive(int* nums, int numsSize) {

int Max = nums[0], i, *Count;

for(i = 1; i<numsSize; i++){
Max = (Max < nums[i]) ? nums[i] : Max;
}

Count = (int*)calloc(Max+1, sizeof(int));
for(i = 0; i<numsSize; i++){
if(nums[i] > 0){
Count[nums[i]]++;
}
}

i = 1;
while(Count[i] != 0){
i++;
}

return i;
}
20 changes: 20 additions & 0 deletions solution/0066.Plus One/Solution.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions solution/0066.Plus One/Solution2.py
Original file line number Diff line number Diff line change
@@ -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)))