![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
堆/leetcode
LUCASYAN个
这个作者很懒,什么都没留下…
展开
-
编程之 最小的K个数 216 Kth Largest Element in an Array 378. Kth Smallest Element in a Sorted Matrix
1、leetcode 215. Kth Largest Element in an Array 剑指offer 40最小的k个数题意:在一个未排序数组中找到第K大的数并输出(1)排序之后直接输出倒数第K个数 时间复杂度O(nlogn),空间复杂度O(1)public int findKthLargest(int[] nums, int k) { final int原创 2017-09-01 21:23:00 · 342 阅读 · 0 评论 -
leetcode 23. Merge k Sorted Lists 合并k个排序链表 优先级队列
1、使用优先级队列建立一个最小堆,保存这k个链表,最小堆的排序规则是链表首元素的大小比较,较小的排在前面。建立一个新的表头,对于堆顶,依次连接,如果堆顶的链表还有下面的元素,将其放入堆中,依次进行,知道链表为空。注意链表为空的情况。/** * Definition for singly-linked list. * struct ListNode { * int val;原创 2017-09-13 11:30:35 · 306 阅读 · 0 评论 -
313. Super Ugly Number
Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13,原创 2017-09-13 14:50:20 · 123 阅读 · 0 评论 -
451. Sort Characters By Frequency 堆
Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.So 'e原创 2017-09-14 10:37:55 · 155 阅读 · 0 评论 -
659. Split Array into Consecutive Subsequences 堆、优先级队列、哈希表
You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences consist of at least 3 consecutive integers.原创 2017-09-14 13:45:50 · 233 阅读 · 0 评论 -
502. IPO
Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it原创 2017-09-02 18:25:16 · 234 阅读 · 0 评论