29 const std::string& string_b) {
30 const auto size_a = string_a.size();
31 const auto size_b = string_b.size();
32 std::vector<std::vector<std::size_t>> sub_sols(
33 size_a + 1, std::vector<std::size_t>(size_b + 1, 0));
35 const auto limit =
static_cast<std::size_t
>(-1);
36 for (std::size_t pos_a = size_a - 1; pos_a != limit; --pos_a) {
37 for (std::size_t pos_b = size_b - 1; pos_b != limit; --pos_b) {
38 if (string_a[pos_a] == string_b[pos_b]) {
39 sub_sols[pos_a][pos_b] = 1 + sub_sols[pos_a + 1][pos_b + 1];
41 sub_sols[pos_a][pos_b] = std::max(sub_sols[pos_a + 1][pos_b],
42 sub_sols[pos_a][pos_b + 1]);
47 return sub_sols[0][0];
55 const std::string string_a;
56 const std::string string_b;
57 const std::size_t common_string_len;
59 TestCase(std::string string_a, std::string string_b,
60 const std::size_t in_common_string_len)
61 : string_a(std::move(string_a)),
62 string_b(std::move(string_b)),
63 common_string_len(in_common_string_len) {}