Minimum Size Subarray Sum

This commit is contained in:
2022-11-29 18:25:47 +08:00
parent 1e65cff7e5
commit 80ee14486c
8 changed files with 184 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "s0076_minimum_window_substring.hpp"
#include <gtest/gtest.h>
TEST(Problem76, Case1) {
string s{"ADOBECODEBANC"};
string t{"ABC"};
string expected{"BANC"};
Solution solution;
EXPECT_EQ(solution.minWindow(s, t), expected);
}
TEST(Problem76, Case2) {
string s{"a"};
string t{"a"};
string expected{"a"};
Solution solution;
EXPECT_EQ(solution.minWindow(s, t), expected);
}
TEST(Problem76, Case3) {
string s{"a"};
string t{"aa"};
string expected{""};
Solution solution;
EXPECT_EQ(solution.minWindow(s, t), expected);
}

View File

@@ -0,0 +1,35 @@
#include "s0209_minimum_size_subarray_sum.hpp"
#include <gtest/gtest.h>
TEST(Problem209, Case1) {
int target{7};
vector<int> nums{2, 3, 1, 2, 4, 3};
int o{2};
Solution solution;
EXPECT_EQ(solution.minSubArrayLen(target, nums), o);
}
TEST(Problem209, Case2) {
int target{4};
vector<int> nums{1, 4, 4};
int o{1};
Solution solution;
EXPECT_EQ(solution.minSubArrayLen(target, nums), o);
}
TEST(Problem209, Case3) {
int target{11};
vector<int> nums{1, 1, 1, 1, 1, 1, 1, 1};
int o{0};
Solution solution;
EXPECT_EQ(solution.minSubArrayLen(target, nums), o);
}
TEST(Problem209, Case4) {
int target{11};
vector<int> nums{1, 2, 3, 4, 5};
int o{3};
Solution solution;
EXPECT_EQ(solution.minSubArrayLen(target, nums), o);
}