Compare commits
No commits in common. "aabf07d9ec32d9c7df5e671a809c972ee8a07416" and "7619dbdaaa0e33641fc15f8c39b0d1c3505fe082" have entirely different histories.
aabf07d9ec
...
7619dbdaaa
@ -13,19 +13,15 @@ add_compile_options(
|
||||
-Wextra
|
||||
-O0
|
||||
-g3
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
add_compile_options(
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
)
|
||||
add_link_options(
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
)
|
||||
endif ()
|
||||
add_link_options(
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
)
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
|
25
src/119.c
25
src/119.c
@ -1,25 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Note: The returned array must be malloced, assume caller calls free().
|
||||
*/
|
||||
int *getRow(int rowIndex, int *returnSize)
|
||||
{
|
||||
int *ret = NULL;
|
||||
|
||||
*returnSize = sizeof(int) * rowIndex + 1;
|
||||
ret = (int *)malloc(*returnSize);
|
||||
|
||||
if (rowIndex == 0)
|
||||
ret[0] = 1;
|
||||
else if (rowIndex == 1)
|
||||
ret[0] = ret[1] = 1;
|
||||
else
|
||||
{
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
38
src/168.c
38
src/168.c
@ -1,38 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char *convertToTitle(int columnNumber)
|
||||
{
|
||||
char *ret = malloc(2);
|
||||
int size = 1;
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
columnNumber--;
|
||||
const int mod = columnNumber % 26;
|
||||
columnNumber /= 26;
|
||||
ret[size - 1] = 'A' + mod;
|
||||
|
||||
size++;
|
||||
ret = realloc(ret, size + 1);
|
||||
}
|
||||
|
||||
ret[size - 1] = '\0';
|
||||
|
||||
for (int i = 0, j = size - 2; i < j; i++, j--)
|
||||
{
|
||||
const char tmp = ret[i];
|
||||
ret[i] = ret[j];
|
||||
ret[j] = tmp;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char *ans = convertToTitle(2147483647);
|
||||
printf("%s\n", ans);
|
||||
free(ans);
|
||||
return 0;
|
||||
}
|
32
src/219.c
32
src/219.c
@ -1,32 +0,0 @@
|
||||
//
|
||||
// Created by xfj12 on 2025/3/24.
|
||||
//
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool containsNearbyDuplicate(int *nums, int numsSize, int k)
|
||||
{
|
||||
for (int i = 0; i < numsSize; i++)
|
||||
{
|
||||
for (int j = i; j < numsSize; j++)
|
||||
{
|
||||
if (abs(i - j) > k)
|
||||
continue;
|
||||
if (nums[i] == nums[j] && i != j)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int nums1[] = {1, 2, 3, 1};
|
||||
assert(containsNearbyDuplicate(nums1, sizeof(nums1) / sizeof(int), 3) == true);
|
||||
int nums2[] = {1, 0, 1, 1};
|
||||
assert(containsNearbyDuplicate(nums2, sizeof(nums2) / sizeof(int), 1) == true);
|
||||
int nums3[] = {1, 2, 3, 1, 2, 3};
|
||||
assert(containsNearbyDuplicate(nums3, sizeof(nums3) / sizeof(int), 2) == false);
|
||||
}
|
15
src/258.c
15
src/258.c
@ -1,15 +0,0 @@
|
||||
//
|
||||
// Created by xfj12 on 2025/3/24.
|
||||
//
|
||||
int addDigits(int num)
|
||||
{
|
||||
int total = 0;
|
||||
do
|
||||
{
|
||||
|
||||
} while ();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
21
src/3110.c
21
src/3110.c
@ -1,21 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
//
|
||||
// Created by xfj12 on 2025/3/24.
|
||||
//
|
||||
|
||||
int scoreOfString(char *s)
|
||||
{
|
||||
int score = 0;
|
||||
for (int i = 0; i < strlen(s) - 1; i++)
|
||||
score += abs(s[i] - s[i + 1]);
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(scoreOfString("hello") == 13);
|
||||
assert(scoreOfString("zaz") == 50);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user