Compare commits

..

12 Commits

Author SHA1 Message Date
6e2206cabe Update Ubuntu mirror in test.yaml for dependency installation
Some checks failed
Gitea CTest Workflow / test (push) Failing after 1m34s
2026-02-05 00:07:55 +08:00
89a41445ef Update minimum CMake version to 3.25 in CMakeLists.txt
Some checks failed
Gitea CTest Workflow / test (push) Has been cancelled
2026-02-05 00:05:54 +08:00
cdb5602c47 Add step to install dependencies in test.yaml
Some checks failed
Gitea CTest Workflow / test (push) Failing after 6m10s
2026-02-04 23:58:46 +08:00
3559f83475 Replace checkout action with direct git clone command in test.yaml
Some checks failed
Gitea CTest Workflow / test (push) Failing after 4s
2026-02-04 23:57:04 +08:00
6f30721f1b Update checkout action URL in test.yaml to use version 6
Some checks failed
Gitea CTest Workflow / test (push) Failing after 42s
2026-02-04 23:55:46 +08:00
9a8260a3b6 Remove token from test.yaml
Some checks failed
Gitea CTest Workflow / test (push) Failing after 32s
2026-02-04 23:53:07 +08:00
fc2fd50bac Update test.yaml to specify server URL and repository for Git operations
Some checks failed
Gitea CTest Workflow / test (push) Failing after 4s
2026-02-04 23:52:24 +08:00
aa3f652a8f Update repository URL in test.yaml
Some checks failed
Gitea CTest Workflow / test (push) Failing after 4s
2026-02-04 23:47:52 +08:00
b6a1850f48 Update checkout action URL in test.yaml to use the mirror repository
Some checks failed
Gitea CTest Workflow / test (push) Failing after 44s
2026-02-04 23:06:18 +08:00
737c8e17dd Add Gitea CTest workflow configuration
Some checks failed
Gitea CTest Workflow / test (push) Has been cancelled
2026-02-04 22:59:05 +08:00
2cf5db11bd Remove debug compile options from CMakeLists.txt 2025-12-06 00:05:53 +08:00
7ae0aeb744 Implement dynamic programming solution for tribonacci and fix index calculation in sequence matching 2025-12-06 00:03:28 +08:00
4 changed files with 50 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
name: Gitea CTest Workflow
on:
push:
branches: [ "main", "master" ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
run: |
git clone https://cantyonion.site/git/cantyonion/leetcode.git .
- name: Install Dependencies
run: |
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources
sudo apt-get update
sudo apt-get install -y build-essential cmake
- name: Configure CMake
# -B build 创建构建目录,-S . 指定源代码在当前目录
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build with CMake
# 使用 --parallel 充分利用 Runner 核心数
run: cmake --build build --parallel $(nproc)
- name: Run CTest via CMake
# 在 build 目录下运行 ctest
# --output-on-failure 可以在测试失败时直接看到 log
run: |
cd build
ctest --output-on-failure --parallel $(nproc)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.30) cmake_minimum_required(VERSION 3.25)
project(leetcode C CXX) project(leetcode C CXX)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
@@ -18,9 +18,6 @@ include(FetchContent)
add_compile_options( add_compile_options(
-Wall -Wall
-Wextra -Wextra
-O0
-g3
-fno-omit-frame-pointer
) )
if (UNIX) if (UNIX)

View File

@@ -4,4 +4,14 @@
#include <solution/1137.h> #include <solution/1137.h>
int tribonacci(int n) int tribonacci(int n)
{ {
int dp[n + 1];
dp[0] = 0;
if (n >= 1)
dp[1] = 1;
if (n >= 2)
dp[2] = 1;
for (int i = 3; i <= n; i++)
dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
return dp[n];
} }

View File

@@ -14,19 +14,20 @@ int maxRepeating(char *sequence, char *word)
return 0; return 0;
int dp[n]; int dp[n];
memset(dp, 0, sizeof(dp));
for (int i = m - 1; i < n; i++) for (int i = m - 1; i < n; i++)
{ {
bool valid = true; bool valid = true;
for (int j = 0; j < m; j++) for (int j = 0; j < m; j++)
{ {
if (sequence[i - m + 1] != word[j]) if (sequence[i - m + 1 + j] != word[j])
{ {
valid = false; valid = false;
break; break;
} }
} }
if (valid) if (valid)
dp[i] = (i == m - 1 ? 0 : dp[i - m] + 1); dp[i] = (i == m - 1 ? 0 : dp[i - m]) + 1;
} }
int ret = dp[0]; int ret = dp[0];