Skip to content

Commit da25674

Browse files
committed
style: use string instead of str
1 parent 6e7fd80 commit da25674

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

dynamic_programming/longest_common_string.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
* @brief computes the length of the longest common string created from input
1717
* strings
1818
* @details has O(str_a.size()*str_b.size()) time and memory complexity
19-
* @param str_a first input string
20-
* @param str_b second input string
19+
* @param string_a first input string
20+
* @param string_b second input string
2121
* @returns the length of the longest common string which can be strated from
2222
* str_a and str_b
2323
*/
24-
std::size_t longest_common_string_length(const std::string& str_a,
25-
const std::string& str_b) {
26-
const auto size_a = str_a.size();
27-
const auto size_b = str_b.size();
24+
std::size_t longest_common_string_length(const std::string& string_a,
25+
const std::string& string_b) {
26+
const auto size_a = string_a.size();
27+
const auto size_b = string_b.size();
2828
std::vector<std::vector<std::size_t>> sub_sols(
2929
size_a + 1, std::vector<std::size_t>(size_b + 1, 0));
3030

3131
const auto limit = static_cast<std::size_t>(-1);
3232
for (std::size_t pos_a = size_a - 1; pos_a != limit; --pos_a) {
3333
for (std::size_t pos_b = size_b - 1; pos_b != limit; --pos_b) {
34-
if (str_a[pos_a] == str_b[pos_b]) {
34+
if (string_a[pos_a] == string_b[pos_b]) {
3535
sub_sols[pos_a][pos_b] = 1 + sub_sols[pos_a + 1][pos_b + 1];
3636
} else {
3737
sub_sols[pos_a][pos_b] = std::max(sub_sols[pos_a + 1][pos_b],
@@ -44,14 +44,14 @@ std::size_t longest_common_string_length(const std::string& str_a,
4444
}
4545

4646
struct TestCase {
47-
const std::string str_a;
48-
const std::string str_b;
47+
const std::string string_a;
48+
const std::string string_b;
4949
const std::size_t common_string_len;
5050

51-
TestCase(std::string in_str_a, std::string in_str_b,
51+
TestCase(std::string string_a, std::string string_b,
5252
const std::size_t in_common_string_len)
53-
: str_a(std::move(in_str_a)),
54-
str_b(std::move(in_str_b)),
53+
: string_a(std::move(string_a)),
54+
string_b(std::move(string_b)),
5555
common_string_len(in_common_string_len) {}
5656
};
5757

@@ -79,7 +79,7 @@ std::vector<TestCase> get_test_cases() {
7979
template <typename TestCases>
8080
void test_longest_common_string_length(const TestCases& test_cases) {
8181
for (const auto& cur_tc : test_cases) {
82-
assert(longest_common_string_length(cur_tc.str_a, cur_tc.str_b) ==
82+
assert(longest_common_string_length(cur_tc.string_a, cur_tc.string_b) ==
8383
cur_tc.common_string_len);
8484
}
8585
}
@@ -94,7 +94,7 @@ template <typename TestCases>
9494
void test_longest_common_string_length_is_symmetric(
9595
const TestCases& test_cases) {
9696
for (const auto& cur_tc : test_cases) {
97-
assert(longest_common_string_length(cur_tc.str_b, cur_tc.str_a) ==
97+
assert(longest_common_string_length(cur_tc.string_b, cur_tc.string_a) ==
9898
cur_tc.common_string_len);
9999
}
100100
}
@@ -119,8 +119,8 @@ template <typename TestCases>
119119
void test_longest_common_string_length_for_reversed_inputs(
120120
const TestCases& test_cases) {
121121
for (const auto& cur_tc : test_cases) {
122-
assert(longest_common_string_length(reverse_str(cur_tc.str_a),
123-
reverse_str(cur_tc.str_b)) ==
122+
assert(longest_common_string_length(reverse_str(cur_tc.string_a),
123+
reverse_str(cur_tc.string_b)) ==
124124
cur_tc.common_string_len);
125125
}
126126
}

0 commit comments

Comments
 (0)