Priority Queue
1 | class Solution { |
QuickSort
1 | class Solution { |
该解法效率不高的原因为为 pivotIndex
左右侧的数组都进行了排序,可以优化为仅对 targetIndex
一侧的数组进行排序。
QuickSort
1 | class Solution { |
QuickSort
1 | class Solution { |
QuickSort + Two Pointers
1 | class Solution { |
1 | class Solution { |
1 | class Solution { |
该解法效率不高的原因为为 pivotIndex
左右侧的数组都进行了排序,可以优化为仅对 targetIndex
一侧的数组进行排序。
1 | class Solution { |
1 | class Solution { |
1 | class Solution { |