diff --git a/include/solution/3202.h b/include/solution/3202.h new file mode 100644 index 0000000..bcde9bd --- /dev/null +++ b/include/solution/3202.h @@ -0,0 +1,11 @@ +#ifndef INC_3202_H +#define INC_3202_H +#ifdef __cplusplus +extern "C" +{ +#endif + int maximumLength(int *nums, int numsSize, int k); +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/3202.c b/src/3202.c new file mode 100644 index 0000000..cc131b4 --- /dev/null +++ b/src/3202.c @@ -0,0 +1,5 @@ +#include + +int maximumLength(int *nums, int numsSize, int k) +{ +} \ No newline at end of file diff --git a/tests/test_3202.cpp b/tests/test_3202.cpp new file mode 100644 index 0000000..48b2dbe --- /dev/null +++ b/tests/test_3202.cpp @@ -0,0 +1,25 @@ +#include +#include + +class MaximumLengthWithKTest : public ::testing::Test +{ + protected: + void AssertMaximumLength(const std::vector &nums, int k, int expected) + { + int *arr = const_cast(nums.data()); + int result = maximumLength(arr, nums.size(), k); + EXPECT_EQ(result, expected); + } +}; + +// 示例 1:nums = [1,2,3,4,5], k = 2 => 输出 5 +TEST_F(MaximumLengthWithKTest, AllIncreasing) +{ + AssertMaximumLength({1, 2, 3, 4, 5}, 2, 5); +} + +// 示例 2:nums = [1,4,2,3,1,4], k = 3 => 输出 4 +TEST_F(MaximumLengthWithKTest, AlternatingValidPairs) +{ + AssertMaximumLength({1, 4, 2, 3, 1, 4}, 3, 4); +} \ No newline at end of file