From 1bd573aded11ef610343d83d4efa045111d6d708 Mon Sep 17 00:00:00 2001 From: Shyam-Chen Date: Tue, 7 Jan 2025 15:12:36 +0800 Subject: [PATCH] 261st Commit --- src/page-1/72. Edit Distance/README.md | 2 +- .../README.md | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/page-11/1071. Greatest Common Divisor of Strings/README.md diff --git a/src/page-1/72. Edit Distance/README.md b/src/page-1/72. Edit Distance/README.md index 778c389..be28fdd 100644 --- a/src/page-1/72. Edit Distance/README.md +++ b/src/page-1/72. Edit Distance/README.md @@ -1,6 +1,6 @@ # 72. 編輯距離 (Edit Distance) -給定兩個字串 word1 和 word2,返回將 word1 轉換為 word2 所使用的最少操作數。 +給定兩個字串 `word1` 和 `word2`,返回將 `word1` 轉換為 `word2` 所使用的最少操作數。 你可以對字詞進行以下三種操作: diff --git a/src/page-11/1071. Greatest Common Divisor of Strings/README.md b/src/page-11/1071. Greatest Common Divisor of Strings/README.md new file mode 100644 index 0000000..c218dea --- /dev/null +++ b/src/page-11/1071. Greatest Common Divisor of Strings/README.md @@ -0,0 +1,34 @@ +# 1071. 字串的最大公因數 (Greatest Common Divisor of Strings) + +對於兩個字串 `s` 和 `t`,只有在 `s = t + t + t + ... + t + t` (即 `t` 與自身連接一次或多次) 時,我們才認定「`t` 可以整除 `s`」。 + +給定兩個字串 `str1` 和 `str2`,返回最長的字串 `x`,使得 `x` 可以同時整除 `str1` 和 `str2`。 + +範例 1: + +```coffee +輸入: str1 = "ABCABC", str2 = "ABC" +輸出: "ABC" +``` + +範例 2: + +```coffee +輸入: str1 = "ABABAB", str2 = "ABAB" +輸出: "AB" +``` + +範例 3: + +```coffee +輸入: str1 = "LEET", str2 = "CODE" +輸出: "" +``` + +## 解題 + +```ts +export const gcdOfStrings: GcdOfStrings = (str1, str2) => { + // +}; +```