StringOverlap
Rookie SRM 18 · 2022-10-10 · by erinn
Problem Statement
You are given two
For example, "BIGTOP" and "TOPCODER" have an overlap of length 3, with the substring "TOP".
On the other hand, the strings "HELLO" and "GOODBYE" have an overlap of length 0.
Return the length of the maximum overlap of the two strings you are given.
Constraints
- s1 and s2 will each contain between 1 and 50 uppercase ('A'-'Z') characters, inclusive.
"TOPCODER" "BIGTOP" Returns: 3
This is an example mentioned in the problem statement.
"HELLO" "GOODBYE" Returns: 0
Also an example from the problem statement.
"CODERTOP" "TOPCODER" Returns: 5
Notice that we can get an overlap regardless of which string we take first, however, one is longer (5) than the other (3).
"STRINGA" "STRINGB" Returns: 0
The strings are almost identical, but putting one after the other, there's no overlap.
"STRING" "STRING" Returns: 6
The strings completely overlap in this case.
Submissions are judged against all 7 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class StringOverlap with a public method int largestOverlap(string s1, string s2) · 7 test cases · 2 s / 256 MB per case