Retranslate the complete Japanese online edition from Chinese (#2008)

* Retranslate the complete Japanese online edition from Chinese

* Fit Japanese homepage labels and localize heading permalinks

* Point Japanese contribution instructions to the Japanese preview

* Replace locale conditionals with multilingual UI tables
This commit is contained in:
Yudong Jin
2026-10-30 02:12:26 +08:00
committed by GitHub
parent 455e8c1281
commit 7257641e0e
1987 changed files with 23531 additions and 23261 deletions

View File

@@ -7,21 +7,21 @@
namespace hello_algo.chapter_dynamic_programming;
public class edit_distance {
/* 編集距離:総当たり探索 */
/* 編集距離:全探索 */
int EditDistanceDFS(string s, string t, int i, int j) {
// s と t がともに空なら 0 を返す
// s と t がともに空の場合、0 を返す
if (i == 0 && j == 0)
return 0;
// s が空なら t の長さを返す
// s が空の場合、t の長さを返す
if (i == 0)
return j;
// t が空なら s の長さを返す
// t が空の場合、s の長さを返す
if (j == 0)
return i;
// 2 つの文字が等しければ、その 2 文字をそのままスキップする
// 2 つの文字が等しい場合、その 2 文字をスキップする
if (s[i - 1] == t[j - 1])
return EditDistanceDFS(s, t, i - 1, j - 1);
// 最小編集回数 = 挿入・削除・置換の 3 操作における最小編集回数 + 1
// 最小編集回数 = 挿入、削除、置換の 3 操作での最小編集回数 + 1
int insert = EditDistanceDFS(s, t, i, j - 1);
int delete = EditDistanceDFS(s, t, i - 1, j);
int replace = EditDistanceDFS(s, t, i - 1, j - 1);
@@ -31,22 +31,22 @@ public class edit_distance {
/* 編集距離:メモ化探索 */
int EditDistanceDFSMem(string s, string t, int[][] mem, int i, int j) {
// s と t がともに空なら 0 を返す
// s と t がともに空の場合、0 を返す
if (i == 0 && j == 0)
return 0;
// s が空なら t の長さを返す
// s が空の場合、t の長さを返す
if (i == 0)
return j;
// t が空なら s の長さを返す
// t が空の場合、s の長さを返す
if (j == 0)
return i;
// 記録済みなら、それをそのまま返す
// 記録済みなら、その値をそのまま返す
if (mem[i][j] != -1)
return mem[i][j];
// 2 つの文字が等しければ、その 2 文字をそのままスキップする
// 2 つの文字が等しい場合、その 2 文字をスキップする
if (s[i - 1] == t[j - 1])
return EditDistanceDFSMem(s, t, mem, i - 1, j - 1);
// 最小編集回数 = 挿入・削除・置換の 3 操作における最小編集回数 + 1
// 最小編集回数 = 挿入、削除、置換の 3 操作での最小編集回数 + 1
int insert = EditDistanceDFSMem(s, t, mem, i, j - 1);
int delete = EditDistanceDFSMem(s, t, mem, i - 1, j);
int replace = EditDistanceDFSMem(s, t, mem, i - 1, j - 1);
@@ -66,14 +66,14 @@ public class edit_distance {
for (int j = 1; j <= m; j++) {
dp[0, j] = j;
}
// 状態遷移: 残りの行と列
// 状態遷移:残りの行と列
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i - 1] == t[j - 1]) {
// 2 つの文字が等しければ、その 2 文字をそのままスキップする
// 2 つの文字が等しい場合、その 2 文字をスキップする
dp[i, j] = dp[i - 1, j - 1];
} else {
// 最小編集回数 = 挿入・削除・置換の 3 操作における最小編集回数 + 1
// 最小編集回数 = 挿入、削除、置換の 3 操作での最小編集回数 + 1
dp[i, j] = Math.Min(Math.Min(dp[i, j - 1], dp[i - 1, j]), dp[i - 1, j - 1]) + 1;
}
}
@@ -81,7 +81,7 @@ public class edit_distance {
return dp[n, m];
}
/* 編集距離:空間最適化した動的計画法 */
/* 編集距離:空間を最適化した動的計画法 */
int EditDistanceDPComp(string s, string t) {
int n = s.Length, m = t.Length;
int[] dp = new int[m + 1];
@@ -98,10 +98,10 @@ public class edit_distance {
for (int j = 1; j <= m; j++) {
int temp = dp[j];
if (s[i - 1] == t[j - 1]) {
// 2 つの文字が等しければ、その 2 文字をそのままスキップする
// 2 つの文字が等しい場合、その 2 文字をスキップする
dp[j] = leftup;
} else {
// 最小編集回数 = 挿入・削除・置換の 3 操作における最小編集回数 + 1
// 最小編集回数 = 挿入、削除、置換の 3 操作での最小編集回数 + 1
dp[j] = Math.Min(Math.Min(dp[j - 1], dp[j]), leftup) + 1;
}
leftup = temp; // 次の反復の dp[i-1, j-1] に更新する
@@ -118,7 +118,7 @@ public class edit_distance {
// 全探索
int res = EditDistanceDFS(s, t, n, m);
Console.WriteLine("" + s + " を " + t + " に変更するには少なくとも " + res + " 回の編集が必要");
Console.WriteLine("文字列 " + s + " を " + t + " に変更するのに必要な最小編集回数は " + res + " 回");
// メモ化探索
int[][] mem = new int[n + 1][];
@@ -128,14 +128,14 @@ public class edit_distance {
}
res = EditDistanceDFSMem(s, t, mem, n, m);
Console.WriteLine("" + s + " を " + t + " に変更するには少なくとも " + res + " 回の編集が必要");
Console.WriteLine("文字列 " + s + " を " + t + " に変更するのに必要な最小編集回数は " + res + " 回");
// 動的計画法
res = EditDistanceDP(s, t);
Console.WriteLine("" + s + " を " + t + " に変更するには少なくとも " + res + " 回の編集が必要");
Console.WriteLine("文字列 " + s + " を " + t + " に変更するのに必要な最小編集回数は " + res + " 回");
// 空間最適化後の動的計画法
// 空間を最適化した動的計画法
res = EditDistanceDPComp(s, t);
Console.WriteLine("" + s + " を " + t + " に変更するには少なくとも " + res + " 回の編集が必要");
Console.WriteLine("文字列 " + s + " を " + t + " に変更するのに必要な最小編集回数は " + res + " 回");
}
}