chore(i18n,curriculum): update translations (#43463)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d825a367417b2b2512c89
|
||||
title: Implement Quick Sort
|
||||
title: 实现快速排序
|
||||
challengeType: 1
|
||||
forumTopicId: 301615
|
||||
dashedName: implement-quick-sort
|
||||
@ -8,21 +8,21 @@ dashedName: implement-quick-sort
|
||||
|
||||
# --description--
|
||||
|
||||
Here we will move on to an intermediate sorting algorithm: quick sort. Quick sort is an efficient, recursive divide-and-conquer approach to sorting an array. In this method, a pivot value is chosen in the original array. The array is then partitioned into two subarrays of values less than and greater than the pivot value. We then combine the result of recursively calling the quick sort algorithm on both sub-arrays. This continues until the base case of an empty or single-item array is reached, which we return. The unwinding of the recursive calls return us the sorted array.
|
||||
在这里,我们将继续讨论中间排序算法:快速排序。 快速排序是对数组进行排序的一种有效的,递归的分而治之的方法。 在此方法中,在原始数组中选择一个枢轴值。 然后将该数组分成两个小于和大于数值的子数组。 然后,我们在两个子阵列上结合递归调用快速排序算法的结果。 这一直持续到达到空或单项数组的基本情况,我们返回。 递归调用的展开将返回已排序的数组。
|
||||
|
||||
Quick sort is a very efficient sorting method, providing *O(nlog(n))* performance on average. It is also relatively easy to implement. These attributes make it a popular and useful sorting method.
|
||||
快速排序是一种非常有效的排序方法,平均提供 *O(nlog(n))* 的性能。 它也相对容易实现。 这些属性使其成为一种流行且有用的排序方法。
|
||||
|
||||
**Instructions:** Write a function `quickSort` which takes an array of integers as input and returns an array of these integers in sorted order from least to greatest. While the choice of the pivot value is important, any pivot will do for our purposes here. For simplicity, the first or last element could be used.
|
||||
**说明:** 编写一个函数 `quickSort`,它将整数数组作为输入,并按从最小到最大的排序顺序返回这些整数的数组。 虽然枢轴值的选择很重要,但任何枢轴都可以满足我们的目的。 为简单起见,可以使用第一个或最后一个元素。
|
||||
|
||||
# --hints--
|
||||
|
||||
`quickSort` should be a function.
|
||||
`quickSort` 应该是一个函数。
|
||||
|
||||
```js
|
||||
assert(typeof quickSort == 'function');
|
||||
```
|
||||
|
||||
`quickSort` should return a sorted array (least to greatest).
|
||||
`quickSort` 应该返回一个排序的数组(从最小到最大)。
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -50,7 +50,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])` should return an array that is unchanged except for order.
|
||||
`quickSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92])` 应该返回一个数组,除了顺序之外没有变化。
|
||||
|
||||
```js
|
||||
assert.sameMembers(
|
||||
@ -77,7 +77,7 @@ assert.sameMembers(
|
||||
);
|
||||
```
|
||||
|
||||
`quickSort` should not use the built-in `.sort()` method.
|
||||
`quickSort` 不应使用内置的 `.sort()` 方法。
|
||||
|
||||
```js
|
||||
assert(isBuiltInSortUsed());
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: a56138aff60341a09ed6c480
|
||||
title: Inventory Update
|
||||
title: 库存更新
|
||||
challengeType: 5
|
||||
forumTopicId: 16019
|
||||
dashedName: inventory-update
|
||||
@ -8,11 +8,11 @@ dashedName: inventory-update
|
||||
|
||||
# --description--
|
||||
|
||||
Compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in `arr1`). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical order by item.
|
||||
将存储在二维数组中的库存与新交货的二维数组进行比较和更新。 更新当前现有库存物料数量(在 `arr1`)。 如果找不到商品,请将新商品和数量添加到库存数组中。 返回的库存数组应按项目的字母顺序排列。
|
||||
|
||||
# --hints--
|
||||
|
||||
The function `updateInventory` should return an array.
|
||||
函数 `updateInventory` 应该返回一个数组。
|
||||
|
||||
```js
|
||||
assert.isArray(
|
||||
@ -33,7 +33,7 @@ assert.isArray(
|
||||
);
|
||||
```
|
||||
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return an array with a length of 6.
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 应该返回一个长度为 6 的数组。
|
||||
|
||||
```js
|
||||
assert.equal(
|
||||
@ -55,7 +55,7 @@ assert.equal(
|
||||
);
|
||||
```
|
||||
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return `[[88, "Bowling Ball"], [2, "Dirty Sock"], [3, "Hair Pin"], [3, "Half-Eaten Apple"], [5, "Microphone"], [7, "Toothpaste"]]`.
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 应返回`[[88, "Bowling Ball"], [2, "Dirty Sock"], [3, "Hair Pin"], [3, "Half-Eaten Apple"], [5, "Microphone"], [7, "Toothpaste"]]`。
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -84,7 +84,7 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [])` should return `[[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]]`.
|
||||
`updateInventory([[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]], [])`应该返回`[[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]]`。
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -106,7 +106,7 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`updateInventory([], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` should return `[[67, "Bowling Ball"], [2, "Hair Pin"], [3, "Half-Eaten Apple"], [7, "Toothpaste"]]`.
|
||||
`updateInventory([], [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]])` 应该返回 `[[67, "Bowling Ball"], [2, "Hair Pin"], [3, "Half-Eaten Apple"], [7, "Toothpaste"]]`。
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -128,7 +128,7 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`updateInventory([[0, "Bowling Ball"], [0, "Dirty Sock"], [0, "Hair Pin"], [0, "Microphone"]], [[1, "Hair Pin"], [1, "Half-Eaten Apple"], [1, "Bowling Ball"], [1, "Toothpaste"]])` should return `[[1, "Bowling Ball"], [0, "Dirty Sock"], [1, "Hair Pin"], [1, "Half-Eaten Apple"], [0, "Microphone"], [1, "Toothpaste"]]`.
|
||||
`updateInventory([[0, "Bowling Ball"], [0, "Dirty Sock"], [0, "Hair Pin"], [0, "Microphone"]], [[1, "Hair Pin"], [1, "Half-Eaten Apple"], [1, "Bowling Ball"], [1, "Toothpaste"]])` 应返回 `[[1, "Bowling Ball"], [0, "Dirty Sock"], [1, "Hair Pin"], [1, "Half-Eaten Apple"], [0, "Microphone"], [1, "Toothpaste"]]`。
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
|
Reference in New Issue
Block a user