Skip to content

Commit c9dba3a

Browse files
committed
docs: added diagram for monoqueue
1 parent 8d42c57 commit c9dba3a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/dataStructures/queue/MonotonicQueue.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
* max()
1212
* pop()
1313
* push()
14-
* @param <T> generic type for objects to be stored or queried
14+
* @param <T> generic type for objects to be stored or queried
15+
*
16+
* index v Increasing queue Decreasing queue
17+
* 1 5 [5] [5]
18+
* 2 3 [3] 3 kick out 5 [5, 3] #3->5
19+
* 3 1 [1] 1 kick out 3 [5, 3, 1] #1->3
20+
* 4 2 [1, 2] #2->1 [5, 3, 2] 2 kick out 1 #2->3
21+
* 5 4 [1, 2, 4] #4->2 [5,4] 4 kick out 2, 3 #4->2
1522
*/
1623
public class MonotonicQueue<T extends Comparable<T>> {
1724
private Deque<Pair<T>> dq = new ArrayDeque<>(); // or LinkedList

0 commit comments

Comments
 (0)