Leetcode 1071: Greatest Common Divisor of Strings

Brute Force: Algorithm Find the shorter string among str1 and str2, without loss of generality, let it be str1. Start with base = str1, and check if both str1 and str2 are made of multiples of base. If so, return base. Otherwise, we shall try a shorter string by removing the last character from base. If we have checked all prefix strings without finding the GCD string, […]

Leetcode 1071: Greatest Common Divisor of Strings Read More »