1071
-
[LeetCode] 1071. Greatest Common Divisor of StringsIT Study/LeetCode 2025. 1. 19. 16:02
1. 문제더보기 문제 설명두 문자열 str1과 str2가 주어졌을 때, 두 문자열을 모두 나눌 수 있는 가장 긴 공통 문자열을 구하는 문제입니다.문자열 t가 문자열 s를 나눌 수 있으려면, 다음 조건을 만족해야 합니다.s = t + t + ... + t (t가 반복되어 s를 구성) 예시입력: str1 = "ABCABC", str2 = "ABC" → 출력: "ABC"입력: str1 = "ABABAB", str2 = "ABAB" → 출력: "AB"입력: str1 = "LEET", str2 = "CODE" → 출력: "" 실제 문제For two strings s and t, we say "t divides s" if and only if s = t + t + t + ... + t + t (i.e., t is ..