``` class Solution { public int findKthLargest(int[] nums, int k) { PriorityQueue h = new PriorityQueue((n1,n2)->n1-n2); for(int i:nums){ h.add(i); if... ...
分类:
其他好文 时间:
2020-02-24 00:46:36
阅读次数:
80
"前言" "Executor 框架概览" "Executor" "ExecutorService" "ScheduledExecutorService" "ThreadPoolExecutor" "ScheduledThreadPoolExecutor" "Executors" "结语" 前言 在学 ...
分类:
编程语言 时间:
2020-02-23 16:25:52
阅读次数:
81
1、模拟弱网环境 打开Fiddler,Rules->Performance->勾选 Simulate Modem Speeds,勾选之后访问网站会发现网络慢了很多 2、Fiddler弱网的原理 Rules—>Cutomize Rules打开CustomRules.js 文档 在文件中搜索关键字,m_ ...
分类:
其他好文 时间:
2020-02-21 18:06:22
阅读次数:
70
https://java-er.com/blog/priority-java-operation/Java的运算符优先级算术运算符优先级较高,关系和逻辑运算符优先级较低。多数运算符具有左结合性,单目运算符、三目运算符、赋值运算符具有右结合性。类别操作符关联性后缀()[].(点操作符)左到右一元!、+、-、~、++、–从右到左乘性、/、%左到右加性+–左到右移位>>>>>
分类:
编程语言 时间:
2020-02-19 14:43:13
阅读次数:
100
思路:AcWing 54. 数据流中的中位数 将数组分成两半,一个大顶堆和一个小顶堆,大顶堆维护小于中位数的所有元素,小顶堆维护大于中位数的所有元素,两个堆的元素数量差不能超过2,超过2就互相匀一匀。 代码: class Solution { priority_queue<int> maxHeap; ...
分类:
其他好文 时间:
2020-02-17 14:04:03
阅读次数:
62
这个用优先队列就可以了。 在这里补充一点优先队列和队列的知识。 优先队列 大根堆:从大到小排列。小根堆:从小到大排列。优先队列就是堆,也可以自己手写堆。// 小根堆的写法priority_queue<int,vector<int>,greater<int> > vis;// 大根堆的写法priori ...
分类:
其他好文 时间:
2020-02-16 16:09:34
阅读次数:
70
Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input ...
分类:
其他好文 时间:
2020-02-16 01:07:50
阅读次数:
63
Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twi ...
分类:
其他好文 时间:
2020-02-16 01:05:54
阅读次数:
61
题目标签:Greedy 利用priority queue, 把石头重量都存入 pq, 每次取最大两个比较,存入差值,直到pq 只剩最后一个。 Java Solution: Runtime: 1 ms, faster than 92.5% Memory Usage: 37.1 MB, less tha ...
分类:
其他好文 时间:
2020-02-15 09:16:54
阅读次数:
103