Problem · String
Greatest Common Divisor of Strings
Learn this problemProblem statement
A non-empty string t divides s when s is one or more concatenated copies of t.
Return the longest string that divides both str1 and str2, or the empty string when none exists.
Function
gcdOfStrings(str1: String, str2: String) → StringExamples
Example 1
str1 = "ABCABC"str2 = "ABC"return = "ABC""ABC" repeats twice to form the first string and once to form the second.
Constraints
1 <= str1.length, str2.length <= 100000- Both strings contain uppercase English letters.
More Atlassian problems
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024