Skip to content

Commit 70e55c9

Browse files
committed
nth_ele add testcase
1 parent 8996079 commit 70e55c9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/13_高级排序算法/quick_sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ T(n) = 2T(n/2) + n
128128

129129
# Leetcode
130130

131-
无序数组寻找第 k 大的数字。
131+
无序数组寻找第 k 大的数字,不止一种方法
132132
https://leetcode.com/problems/kth-largest-element-in-an-array/description/

docs/13_高级排序算法/quicksort.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def test_nth_element():
102102
assert nth_element(array, 0, len(array), 1) == 1
103103
assert nth_element(array, 0, len(array), 2) == 2
104104

105+
array = [3,3,3,3,3,3,3,3,3]
106+
assert nth_element(array, 0, len(array), 1) == 3
107+
105108

106109
if __name__ == '__main__':
107110
test_nth_element()

0 commit comments

Comments
 (0)