From 2d5d93472a0fe70f461fc355af6af2b6a5e8dcde Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Thu, 22 Nov 2018 19:33:05 +0530 Subject: [PATCH 1/3] Create Solution.py --- solution/0066.Plus One/Solution.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solution/0066.Plus One/Solution.py 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 From f63987e821a286588ef71060d160b47cec199dd4 Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Thu, 22 Nov 2018 19:37:36 +0530 Subject: [PATCH 2/3] Create Solution2.py Using built-in functions only --- solution/0066.Plus One/Solution2.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 solution/0066.Plus One/Solution2.py 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))) From a3b44820ff5686a20f6b223ab3cdc05500836a7d Mon Sep 17 00:00:00 2001 From: Ashwek Swamy <39827514+ashwek@users.noreply.github.com> Date: Thu, 22 Nov 2018 19:47:30 +0530 Subject: [PATCH 3/3] Create Solution.c --- .../0041.First Missing Positive/Solution.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 solution/0041.First Missing Positive/Solution.c 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; +}