Problem
A string t divides a string s if s is t repeated one or more times ("ABAB" is "AB" twice). Given str1 and str2, return the largest string that divides both of them, or "" if none does.
Example 1
- Input
- str1 = "ABCABC", str2 = "ABC"
- Output
- "ABC"
Example 2
- Input
- str1 = "ABABAB", str2 = "ABAB"
- Output
- "AB"
Example 3
- Input
- str1 = "LEET", str2 = "CODE"
- Output
- ""
Constraints
1 <= str1.length, str2.length <= 1000str1 and str2 consist of uppercase English letters.