mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-23 18:10:20 +08:00
Update 0215.Kth-Largest-Element-in-an-Array.md
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user