Re-translate the Japanese version (#1871)

* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
This commit is contained in:
Yudong Jin
2026-03-30 07:30:15 +08:00
committed by GitHub
parent fe6443235b
commit d7b2277d2b
1444 changed files with 83312 additions and 8363 deletions

View File

@@ -6,8 +6,8 @@ Author: krahets (krahets@163.com)
def two_sum_brute_force(nums: list[int], target: int) -> list[int]:
"""方法一:ブルートフォース列挙"""
# 重ループ、時間計算量は O(n^2)
"""方法 1総当たり列挙"""
# 2重ループのため、時間計算量は O(n^2)
for i in range(len(nums) - 1):
for j in range(i + 1, len(nums)):
if nums[i] + nums[j] == target:
@@ -16,10 +16,10 @@ def two_sum_brute_force(nums: list[int], target: int) -> list[int]:
def two_sum_hash_table(nums: list[int], target: int) -> list[int]:
"""方法:補助ハッシュテーブル"""
# 補助ハッシュテーブル、空間計算量は O(n)
"""方法 2:補助ハッシュテーブル"""
# 補助ハッシュテーブルを使用し、空間計算量は O(n)
dic = {}
# 単一ループ、時間計算量は O(n)
# 単一ループ、時間計算量は O(n)
for i in range(len(nums)):
if target - nums[i] in dic:
return [dic[target - nums[i]], i]
@@ -27,16 +27,16 @@ def two_sum_hash_table(nums: list[int], target: int) -> list[int]:
return []
"""ドライバーコード"""
"""Driver Code"""
if __name__ == "__main__":
# ======= テストケース =======
# ======= Test Case =======
nums = [2, 7, 11, 15]
target = 13
# ====== ドライバーコード ======
# 方法
# ====== Driver Code ======
# 方法 1
res: list[int] = two_sum_brute_force(nums, target)
print("方法一の結果 =", res)
# 方法
print("方法1 res =", res)
# 方法 2
res: list[int] = two_sum_hash_table(nums, target)
print("方法二の結果 =", res)
print("方法2 res =", res)