Skip to content

Commit fc66020

Browse files
author
詹龙
committed
0158_Week01 (C)
1 parent bc76aa8 commit fc66020

6 files changed

Lines changed: 74 additions & 8 deletions

File tree

Week_01/G20200343040158/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ project(C C)
33

44
set(CMAKE_C_STANDARD 99)
55

6-
add_executable(C main.c support.h support.c)
6+
add_executable(C main.c support.h support.c LeetCode_21_0158.c LeetCode_88_0158.c LeetCode_283_0158.c LeetCode_66_0158.c)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Created by apple on 2020/3/14.
3+
//
4+
5+
struct ListNode* mergeTwoLists(struct ListNode* l1, struct ListNode* l2){
6+
if (l1 == NULL) {
7+
return l2;
8+
}
9+
if (l2 == NULL) {
10+
return l1;
11+
}
12+
13+
if (l1->val < l2->val) {
14+
l1->next = mergeTwoLists(l1->next, l2);
15+
return l1;
16+
} else {
17+
l2->next = mergeTwoLists(l1, l2->next);
18+
return l2;
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// Created by apple on 2020/3/14.
3+
//
4+
5+
void moveZeroes(int* nums, int numsSize){
6+
if (nums == NULL) {
7+
return;
8+
}
9+
10+
int j = 0;
11+
for (int i = 0; i < numsSize; i++) {
12+
if (nums[i] != 0) {
13+
int t = nums[i];
14+
nums[i] = nums[j];
15+
nums[j++] = t;
16+
}
17+
}
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Created by apple on 2020/3/14.
3+
//
4+
5+
int* plusOne(int* digits, int digitsSize, int* returnSize){
6+
for (int i = digitsSize-1; i >= 0; i--) {
7+
if (digits[i] < 9) {
8+
digits[i]++;
9+
*returnSize = digitsSize;
10+
return digits;
11+
}
12+
digits[i] = 0;
13+
}
14+
int *result = (int*)malloc(sizeof(int)*(digitsSize+1));
15+
result[0] = 1;
16+
for (int i = 1; i < digitsSize+1; i++) {
17+
result[i] = 0;
18+
}
19+
*returnSize = digitsSize+1;
20+
return result;
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by apple on 2020/3/14.
3+
//
4+
5+
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n){
6+
int k = m+n;
7+
for (int i = k-1; i >= 0; i--) {
8+
if ((m > 0 && n > 0 && nums1[m-1] > nums2[n-1]) || n == 0) {
9+
nums1[i] = nums1[--m];
10+
} else {
11+
nums1[i] = nums2[--n];
12+
}
13+
}
14+
}

Week_01/G20200343040158/cmake-build-debug/CMakeFiles/clion-log.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/apple/Desktop/algorithm007-class02/Week_01/G20200343040158
2-
-- The C compiler identification is AppleClang 11.0.0.11000033
3-
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
4-
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
5-
-- Detecting C compiler ABI info
6-
-- Detecting C compiler ABI info - done
7-
-- Detecting C compile features
8-
-- Detecting C compile features - done
92
-- Configuring done
103
CMake Error at CMakeLists.txt:6 (add_executable):
114
Cannot find source file:

0 commit comments

Comments
 (0)