Polish some cotents.

This commit is contained in:
krahets
2023-05-18 20:27:58 +08:00
parent 335bc29af2
commit 399e5df39a
16 changed files with 39 additions and 37 deletions

View File

@ -26,7 +26,7 @@ function binarySearch(nums, target) {
}
/* 二分查找(左闭右开) */
function binarySearch1(nums, target) {
function binarySearchLCRO(nums, target) {
// 初始化左闭右开 [0, n) ,即 i, j 分别指向数组首元素、尾元素+1
let i = 0,
j = nums.length;
@ -56,5 +56,5 @@ let index = binarySearch(nums, target);
console.log('目标元素 6 的索引 = ' + index);
/* 二分查找(左闭右开) */
index = binarySearch1(nums, target);
index = binarySearchLCRO(nums, target);
console.log('目标元素 6 的索引 = ' + index);