Merge pull request #101 from leizhiyuan/patch-1

Update 0215.Kth-Largest-Element-in-an-Array.md
This commit is contained in:
halfrost
2021-02-20 17:13:49 +08:00
committed by GitHub

View File

@@ -73,6 +73,19 @@ func selection(arr []int, l, r, k int) int {
}
}
func partition164(a []int, lo, hi int) int {
pivot := a[hi]
i := lo - 1
for j := lo; j < hi; j++ {
if a[j] < pivot {
i++
a[j], a[i] = a[i], a[j]
}
}
a[i+1], a[hi] = a[hi], a[i+1]
return i + 1
}
```