摘要: 快速选择算法,是一种能在大致O(N)的时间内选取数组中第k大或者k小的算法.其基本思路与快速排序算法类似,也是分治的思想. 其实这个算法是个基础算法,但是不常用,所以今天编的时候错了POJ2388,才有了这篇文章. 下面几段代码,尤其要注意的是 while(i<j) 还是 while(i<=j) 程 阅读全文
posted @ 2017-03-21 08:16 CodesKiller 阅读(5158) 评论(0) 推荐(0) 编辑
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-03-21 07:56 CodesKiller 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum 阅读全文
posted @ 2017-03-21 06:25 CodesKiller 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each elemen 阅读全文
posted @ 2017-03-21 02:36 CodesKiller 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i 阅读全文
posted @ 2017-03-21 01:58 CodesKiller 阅读(120) 评论(0) 推荐(0) 编辑
摘要: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
posted @ 2017-03-21 01:05 CodesKiller 阅读(142) 评论(0) 推荐(0) 编辑