父文章 : 人人都是面试_个人渣记录仅为自己搜索用的博客-CSDN博客
算法leetcode力扣_个人渣记录仅为自己搜索用的博客-CSDN博客
那个谷歌的网红扔鸡蛋的题,来看看教科书式的回答_兔老大RabbitMQ的博客-CSDN博客
不骗你,没读这一篇,你不可能懂二分_兔老大RabbitMQ的博客-CSDN博客
Deque的两个实现类?
LinkedList add/offer是放在后面还是前面 push呢? (push pop 是stack的能力)
ArrayDeque push放在前面怎么实现的?
刷题:Priority queue - 简书优先队列:出队的先后顺序按照优先级来,通常用堆来实现。 215. 数组中的第K个最大元素[https://leetcode-cn.com/problems/kth-large...https://www.jianshu.com/p/b19a0bbd5028
PriorityQueue是什么? 看过后才知道原来这么简单!上篇文章里我们了解到ArrayDeque是Queue的实现,而PriorityQueue是Queue的一种变体实现.在刷算法题的时候经常能用到,今天来讲讲PriorityQueue.概述我们都知道Queue是一个先进先出的队列,而PriorityQueue则是在队列的基础上增加了优先级的特性,是一个基于小顶堆的无解队列.举个栗子: 在游乐园门口有很多人在排队进场,这就是一个`Queue`.这时暴发户小明想插队提前进场,`Queue`显然就不符合了,因为`Queue`是严格按照`F...https://blog.csdn.net/qq_29693653/article/details/109063062?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164606780816780269833914%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=164606780816780269833914&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-6-109063062.pc_search_insert_es_download&utm_term=Priority+queue&spm=1018.2226.3001.4187
LinkedList 全能选手,Deque 既是队列也是queue
Queue
Deque =new LinkedList 栈 (pop push) / 队列 (offer pull) peek 相同
核心是 pop和offer一个是放在头,一个是放在尾. 取 pop/poll 就可以归一成"取头"就好了.
The twelve methods described above are summarized in the following table:
Queue用法
Elements are added at the end of the deque and removed from the beginning. The methods inherited from the Queue interface are precisely equivalent to Deque methods as indicated in the following table:
Comparison of Queue and Deque methods
Stack用法
When a deque is used as a stack, elements are pushed and popped from the beginning of the deque. Stack methods are precisely equivalent to Deque methods as indicated in the table below:
Comparison of Stack and Deque methods
String.toCharArray();
* 尾递归才能变成循环
详见 算法导论