Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1071. Greatest Common Divisor of Strings
Find the longest string x such that both str1 and str2 are formed by repeating x one or more times. Key insight: x must be a prefix whose length divides both string lengths, so check the prefix of length gcd(len(str1), len(str2)) and verify it repeats to form both strings.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.