mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-18 06:20:58 +00:00
Fix multilingual content typos (#1958)
This commit is contained in:
@@ -14,7 +14,7 @@ int binarySearchInsertion(int *nums, int numSize, int target) {
|
||||
if (nums[m] < target) {
|
||||
i = m + 1; // target 在区间 [m+1, j] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
@@ -64,4 +64,4 @@ int main() {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ int binarySearchInsertion(int *nums, int numSize, int target) {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -24,6 +24,6 @@ int main() {
|
||||
size_t hashStr = hash<string>()(str);
|
||||
cout << "字符串 " << str << " 的哈希值为 " << hashStr << "\n";
|
||||
|
||||
// 在 C++ 中,内置 std:hash() 仅提供基本数据类型的哈希值计算
|
||||
// 在 C++ 中,内置 std::hash() 仅提供基本数据类型的哈希值计算
|
||||
// 数组、对象的哈希值计算需要自行实现
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ int binarySearchInsertion(const vector<int> &nums, int target) {
|
||||
if (nums[m] < target) {
|
||||
i = m + 1; // target 在区间 [m+1, j] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -33,7 +33,7 @@ int binarySearchInsertion(vector<int> &nums, int target) {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -34,7 +34,7 @@ public class binary_search_insertion {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -31,7 +31,7 @@ int binarySearchInsertion(List<int> nums, int target) {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -40,7 +40,7 @@ func binarySearchInsertion(nums []int, target int) int {
|
||||
// target 在区间 [i, m-1] 中
|
||||
j = m - 1
|
||||
} else {
|
||||
// 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
// 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class binary_search_insertion {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -33,7 +33,7 @@ function binarySearchInsertion(nums, target) {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -35,7 +35,7 @@ fun binarySearchInsertion(nums: IntArray, target: Int): Int {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1 // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1 // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1 // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
@@ -62,4 +62,4 @@ fun main() {
|
||||
val index = binarySearchInsertion(nums, target)
|
||||
println("元素 $target 的插入点的索引为 $index")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ def binary_search_insertion(nums: list[int], target: int) -> int:
|
||||
elif nums[m] > target:
|
||||
j = m - 1 # target 在区间 [i, m-1] 中
|
||||
else:
|
||||
j = m - 1 # 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1 # 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
# 返回插入点 i
|
||||
return i
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ Created Time: 2024-05-22
|
||||
Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
|
||||
=end
|
||||
|
||||
require 'set'
|
||||
|
||||
### 回溯算法:全排列 II ###
|
||||
def backtrack(state, choices, selected, res)
|
||||
# 当状态长度等于元素数量时,记录解
|
||||
|
||||
@@ -39,7 +39,7 @@ def binary_search_insertion(nums, target)
|
||||
elsif nums[m] > target
|
||||
j = m - 1 # target 在区间 [i, m-1] 中
|
||||
else
|
||||
j = m - 1 # 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1 # 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn binary_search_insertion(nums: &[i32], target: i32) -> i32 {
|
||||
} else if nums[m as usize] > target {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -35,7 +35,7 @@ public func binarySearchInsertion(nums: [Int], target: Int) -> Int {
|
||||
} else if nums[m] > target {
|
||||
j = m - 1 // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1 // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1 // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
@@ -26,8 +26,8 @@ enum Queue {
|
||||
|
||||
/* 元素出队 */
|
||||
// 使用 Array 模拟时 pop 的复杂度为 O(n)
|
||||
let pool = queue.removeFirst()
|
||||
print("出队元素 pop = \(pool),出队后 queue = \(queue)")
|
||||
let pop = queue.removeFirst()
|
||||
print("出队元素 pop = \(pop),出队后 queue = \(queue)")
|
||||
|
||||
/* 获取队列的长度 */
|
||||
let size = queue.count
|
||||
|
||||
@@ -36,7 +36,7 @@ function binarySearchInsertion(nums: Array<number>, target: number): number {
|
||||
} else if (nums[m] > target) {
|
||||
j = m - 1; // target 在区间 [i, m-1] 中
|
||||
} else {
|
||||
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
|
||||
j = m - 1; // 最右一个小于 target 的元素在区间 [i, m-1] 中
|
||||
}
|
||||
}
|
||||
// 返回插入点 i
|
||||
|
||||
Reference in New Issue
Block a user