Skip to content

Commit a3970cc

Browse files
committed
feat: i18n update
1 parent f74999f commit a3970cc

File tree

9 files changed

+221
-48
lines changed

9 files changed

+221
-48
lines changed

‎src/codeTemplates/backtrack.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,30 @@ module.exports = () => ({
6565
text: `
6666
const visited = {}
6767
function backtrack(i) {
68-
if (满足特定条件){
68+
// 如果满足条件
69+
if (Meet certain conditions) {
6970
// 返回结果 or 退出搜索空间
71+
// return result or exit search space
7072
}
7173
72-
visited[i] = true // 将当前状态标为已搜索
73-
dosomething(i) // 对i做一些操作
74-
for (根据i能到达的下个状态j) {
75-
if (!visited[j]) { // 如果状态j没有被搜索过
74+
// 将当前状态标为已搜索
75+
// mark the current state as searched
76+
visited[i] = true
77+
// 对i做一些操作
78+
// do something with i
79+
dosomething(i)
80+
81+
// for (根据i能到达的下个状态j) {
82+
for (The next state j that can be reached based on i.) {
83+
// 如果状态j没有被搜索过
84+
// if state j has not been searched
85+
if (!visited[j]) {
7686
dfs(j)
7787
}
7888
}
79-
undo(i) // 恢复i
89+
// 恢复i
90+
// restore i
91+
undo(i)
8092
}
8193
backtrack(0)
8294
`,

‎src/codeTemplates/hand-writing.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ module.exports = () => ({
2020
language: "py",
2121
text: `
2222
# 1. 归并排序(推荐!其他排序方法都不推荐在竞赛中使用)
23+
# 1. Merge sort (recommended! None of the other ranking methods are recommended for use in contests)
2324
# 归并排序乞丐版
25+
# Merge sort beggar version
2426
class Solution:
2527
def sortArray(self, nums: List[int]) -> List[int]:
2628
def mergeSort(l, r):
@@ -49,6 +51,7 @@ class Solution:
4951
mergeSort(0, len(nums) - 1)
5052
return nums
5153
# 归并排序优化版
54+
# Merge sort optimization version
5255
class Solution:
5356
def sortArray(self, nums: List[int]) -> List[int]:
5457
temp = [0] * len(nums)
@@ -83,7 +86,9 @@ class Solution:
8386
return nums
8487
8588
# 2. 快速排序
89+
# 2. Quick sort
8690
# 快速排序乞丐版
91+
# Quick sort beggar version
8792
class Solution:
8893
def sortArray(self, nums: List[int]) -> List[int]:
8994
temp = [0] * len(nums)
@@ -98,6 +103,7 @@ class Solution:
98103
99104
return quickSort(nums)
100105
# 快速排序优化版
106+
# Quick sort optimization version
101107
class Solution:
102108
def sortArray(self, nums: List[int]) -> List[int]:
103109
temp = [0] * len(nums)
@@ -126,6 +132,7 @@ class Solution:
126132
return nums
127133
128134
# 3. 插入排序
135+
# 3. Insertion sort
129136
class Solution:
130137
def sortArray(self, nums: List[int]) -> List[int]:
131138
n = len(nums)
@@ -139,6 +146,7 @@ class Solution:
139146
return nums
140147
141148
# 4. 选择排序
149+
# 4. Selection sort
142150
class Solution:
143151
def sortArray(self, nums: List[int]) -> List[int]:
144152
n = len(nums)
@@ -151,6 +159,7 @@ class Solution:
151159
return nums
152160
153161
# 5. 冒泡排序
162+
# 5. Bubble sort
154163
class Solution:
155164
def sortArray(self, nums: List[int]) -> List[int]:
156165
n = len(nums)
@@ -179,6 +188,7 @@ class Solution:
179188
language: "py",
180189
text: `
181190
# 1. 归并排序(推荐!其他排序方法都不推荐在竞赛中使用)
191+
# 1. Merge sort (recommended! None of the other ranking methods are recommended for use in contests)
182192
class Solution:
183193
def sortList(self, head: ListNode) -> ListNode:
184194
def mergeSort(head: ListNode) -> ListNode:
@@ -213,9 +223,11 @@ class Solution:
213223
214224
return mergeSort(head)
215225
# 2. 快速排序
226+
# 2. Quick sort
216227
class Solution:
217228
def sortList(self, head):
218229
# ��坏情况也是 n ^ 2 ,因此面试或者竞赛不建议使用
230+
# The worst case is also n ^ 2, so it is not recommended to use it in interviews or competitions
219231
def quickSort(head, end):
220232
221233
if head != end:
@@ -226,12 +238,15 @@ class Solution:
226238
def partition(head, end):
227239
# p1是写指针,p2是读指针
228240
# 最终 p1 是大的链表的头, head 是小的链表的头
241+
# p1 is the write pointer, p2 is the read pointer
242+
# Finally, p1 is the head of the larger linked list, and head is the head of the smaller linked list
229243
pivot_val = head.val
230244
p1, p2 = head, head.next
231245
232246
while p2 != end:
233247
if p2.val < pivot_val:
234248
# 相当于数组的 append 方法
249+
# Equivalent to the append method of an array
235250
p1 = p1.next
236251
p1.val, p2.val = p2.val, p1.val
237252
p2 = p2.next
@@ -241,6 +256,7 @@ class Solution:
241256
quickSort(head, None)
242257
return head
243258
# 3. 插入排序
259+
# 3. Insertion sort
244260
class Solution:
245261
def sortList(self, head):
246262
if head == None or head.next == None:
@@ -252,21 +268,26 @@ class Solution:
252268
cur = head
253269
while cur:
254270
# 准备将 last 插入到合适位置
271+
# Prepare to insert last into the appropriate position
255272
last = cur.next
256273
if last and last.val < cur.val:
257274
# 从 dummy 到 cur 线性遍历找第一个满足条件的位置并插入
275+
# Linearly traverse from dummy to cur to find the first position that meets the conditions and insert
258276
while pre.next and pre.next.val < last.val:
259277
pre = pre.next
260278
tmp = pre.next
261279
pre.next = last
262-
cur.next = last.next # 别忘了这个,否则成环
280+
# 别忘了这个,否则成环
281+
# Don't forget this, otherwise it will become a ring
282+
cur.next = last.next
263283
last.next = tmp
264284
pre = dummy
265285
else:
266286
cur = last
267287
268288
return dummy.next
269289
# 4. 选择排序
290+
# 4. Selection sort
270291
class Solution:
271292
def sortList(self, head):
272293
temp = head
@@ -282,6 +303,7 @@ class Solution:
282303
temp = temp.next
283304
return head
284305
# 5. 冒泡排序
306+
# 5. Bubble sort
285307
class Solution:
286308
def sortList(self, head):
287309
if not head:

‎src/codeTemplates/prime.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const { t } = require("../locales");
22

33
const pyCode = `
44
MAXN = int(1e5)
5-
flag = [True] * (MAXN + 10) # if flag[i] is true, then i is prime
5+
# 如果 flag[i] 为 true,表示 i 是质数
6+
# if flag[i] is true, then i is prime
7+
flag = [True] * (MAXN + 10)
68
flag[0], flag[1] = False, False
79
for i in range(2, int(MAXN ** 0.5) + 1):
810
if flag[i]:

0 commit comments

Comments
 (0)