Skip to content

Commit 4dc97cd

Browse files
authored
Update 0215.Kth-Largest-Element-in-an-Array.md
1 parent 6c7d4fb commit 4dc97cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

website/content/ChapterFour/0200~0299/0215.Kth-Largest-Element-in-an-Array.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ func selection(arr []int, l, r, k int) int {
7373
}
7474
}
7575

76+
func partition164(a []int, lo, hi int) int {
77+
pivot := a[hi]
78+
i := lo - 1
79+
for j := lo; j < hi; j++ {
80+
if a[j] < pivot {
81+
i++
82+
a[j], a[i] = a[i], a[j]
83+
}
84+
}
85+
a[i+1], a[hi] = a[hi], a[i+1]
86+
return i + 1
87+
}
88+
7689
```
7790

7891

0 commit comments

Comments
 (0)