Loading

摘要: 二分查找实现 非常详细的解释,简单但是细节很重要 https://www.cnblogs.com/kyoner/p/11080078.html 正常实现 Input : [1,2,3,4,5] key : 3 return the index : 2 public int binarySearch( 阅读全文
posted @ 2020-09-22 22:01 kopoo 阅读(70) 评论(0) 推荐(0)
摘要: 排序 快速排序 用于求解 Kth Element 问题,也就是第 K 个元素的问题。 可以使用快速排序的 partition() 进行实现。需要先打乱数组,否则最坏情况下时间复杂度为 O(N2)。 堆排序 用于求解 TopK Elements 问题,也就是 K 个最小元素的问题。可以维护一个大小为 阅读全文
posted @ 2020-09-22 12:43 kopoo 阅读(64) 评论(0) 推荐(0)