Skip to content

Commit 5784ce9

Browse files
committed
Add highlight to func in Ch 1.4
1 parent e2adb7a commit 5784ce9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/c01/p04_find_largest_or_smallest_n_items.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ heapq模块有两个函数:``nlargest()`` 和 ``nsmallest()`` 可以完美解
6565
2
6666
6767
当要查找的元素个数相对比较小的时候,函数 ``nlargest()`` 和 ``nsmallest()`` 是很合适的。
68-
如果你仅仅想查找唯一的最小或最大(N=1)的元素的话,那么使用min()和max()函数会更快些。
68+
如果你仅仅想查找唯一的最小或最大(N=1)的元素的话,那么使用 ``min()`` 和 ``max()`` 函数会更快些。
6969
类似的,如果N的大小和集合大小接近的时候,通常先排序这个集合然后再使用切片操作会更快点
7070
( ``sorted(items)[:N]`` 或者是 ``sorted(items)[-N:]`` )。
71-
需要在正确场合使用函数nlargest() 和 nsmallest()才能发挥它们的优势
71+
需要在正确场合使用函数 ``nlargest()````nsmallest()`` 才能发挥它们的优势
7272
(如果N快接近集合大小了,那么使用排序操作会更好些)。
7373

7474
尽管你没有必要一定使用这里的方法,但是堆数据结构的实现是一个很有趣并且值得你深入学习的东西。

0 commit comments

Comments
 (0)