Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2cd3d35

Browse files
authoredOct 5, 2021
Update number-of-pairs-of-strings-with-concatenation-equal-to-target.cpp
1 parent ec33ae9 commit 2cd3d35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎C++/number-of-pairs-of-strings-with-concatenation-equal-to-target.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Solution {
1515
result += cnt1;
1616
++lookup[size(num)];
1717
}
18-
if (!target.compare(size(target) - size(num), size(num), num)) {
18+
if (!target.compare(size(target) - size(num), size(num), num)) { // in c++ 20, we can directly use ends_with, see https://en.cppreference.com/w/cpp/string/basic_string/ends_with
1919
result += cnt2;
2020
++lookup[-size(num)];
2121
}
@@ -38,10 +38,10 @@ class Solution2 {
3838
if (!target.compare(0, size(num), num)) { // in c++ 20, we can directly use starts_with, see https://en.cppreference.com/w/cpp/string/basic_string/starts_with
3939
result += suffix[size(target) - size(num)];
4040
}
41-
if (!target.compare(size(target) - size(num), size(num), num)) {
41+
if (!target.compare(size(target) - size(num), size(num), num)) { // in c++ 20, we can directly use ends_with, see https://en.cppreference.com/w/cpp/string/basic_string/ends_with
4242
result += prefix[size(target) - size(num)];
4343
}
44-
if (!target.compare(0, size(num), num)) { // in c++ 20, we can directly use ends_with, see https://en.cppreference.com/w/cpp/string/basic_string/ends_with
44+
if (!target.compare(0, size(num), num)) {
4545
++prefix[size(num)];
4646
}
4747
if (!target.compare(size(target) - size(num), size(num), num)) {

0 commit comments

Comments
 (0)
Please sign in to comment.