3202
This commit is contained in:
11
include/solution/3202.h
Normal file
11
include/solution/3202.h
Normal file
@@ -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
|
||||
5
src/3202.c
Normal file
5
src/3202.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <solution/3202.h>
|
||||
|
||||
int maximumLength(int *nums, int numsSize, int k)
|
||||
{
|
||||
}
|
||||
25
tests/test_3202.cpp
Normal file
25
tests/test_3202.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <solution/3202.h>
|
||||
|
||||
class MaximumLengthWithKTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void AssertMaximumLength(const std::vector<int> &nums, int k, int expected)
|
||||
{
|
||||
int *arr = const_cast<int *>(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);
|
||||
}
|
||||
Reference in New Issue
Block a user