Leetcode 题解 - 排序.md 1. Kth Element

This commit is contained in:
wunsiang 2019-08-30 19:00:27 +08:00
parent 5b88733982
commit 93145c7da5

View File

@ -82,8 +82,8 @@ public int findKthLargest(int[] nums, int k) {
private int partition(int[] a, int l, int h) {
int i = l, j = h + 1;
while (true) {
while (a[++i] < a[l] && i < h) ;
while (a[--j] > a[l] && j > l) ;
while (i < h && a[++i] <= a[l]) ;
while (j > l && a[--j] >= a[l]) ;
if (i >= j) {
break;
}
@ -196,7 +196,6 @@ public String frequencySort(String s) {
<div align="center"> <img src="pics/7a3215ec-6fb7-4935-8b0d-cb408208f7cb.png"/> </div><br>
## 1. 按颜色进行排序
[75. Sort Colors (Medium)](https://leetcode.com/problems/sort-colors/description/)