mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-23 18:11:45 +08:00
build
This commit is contained in:
@@ -8,7 +8,9 @@ comments: true
|
||||
|
||||
我们先来求解一个简单的二分查找问题。
|
||||
|
||||
!!! question "给定一个长度为 $n$ 的有序数组 `nums` ,元素按从小到大的顺序排列。查找并返回元素 `target` 在该数组中的索引。若数组中不包含该元素,则返回 $-1$ 。数组中不包含重复元素。"
|
||||
!!! question
|
||||
|
||||
给定一个长度为 $n$ 的有序数组 `nums` ,元素按从小到大的顺序排列。请查找并返回元素 `target` 在该数组中的索引。若数组中不包含该元素,则返回 $-1$ 。数组中不包含重复元素。
|
||||
|
||||
该数组的索引范围可以使用区间 $[0, n - 1]$ 来表示。其中,**中括号表示“闭区间”,即包含边界值本身**。在该表示下,区间 $[i, j]$ 在 $i = j$ 时仍包含一个元素,在 $i > j$ 时为空区间。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user