mirror of
https://github.com/krahets/hello-algo.git
synced 2026-09-19 21:17:15 +00:00
Mention figures and tables in normal texts.
Fix some figures. Finetune texts.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
## 线性查找:以时间换空间
|
||||
|
||||
考虑直接遍历所有可能的组合。开启一个两层循环,在每轮中判断两个整数的和是否为 `target` ,若是,则返回它们的索引。
|
||||
考虑直接遍历所有可能的组合。如下图所示,我们开启一个两层循环,在每轮中判断两个整数的和是否为 `target` ,若是则返回它们的索引。
|
||||
|
||||

|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
## 哈希查找:以空间换时间
|
||||
|
||||
考虑借助一个哈希表,键值对分别为数组元素和元素索引。循环遍历数组,每轮执行:
|
||||
考虑借助一个哈希表,键值对分别为数组元素和元素索引。循环遍历数组,每轮执行下图所示的步骤。
|
||||
|
||||
1. 判断数字 `target - nums[i]` 是否在哈希表中,若是则直接返回这两个元素的索引。
|
||||
2. 将键值对 `nums[i]` 和索引 `i` 添加进哈希表。
|
||||
|
||||
Reference in New Issue
Block a user