# Questions tagged [deque]

For code for double ended queues, or code that wouldn't nearly be the same without a deque. Not for code that merely happens to use a deque incidentally but whose real focus is something else.

18 questions
Filter by
Sorted by
Tagged with
331 views

### C++ Deque Implementation

Took a shot at implementing std::deque in C++. I aimed for amortized O(1) push_front and <...
• 361
689 views

### New York Times' Digits Game Solver

I wrote an algorithm to solve the New York Times' Puzzle: Digits. You could play the game here. The rules of the game are as follow: You were given 6 numbers and you could use simple operations (plus, ...
154 views

### Take in 10 numbers, validate each input, append then in a list and then prints the sum of the list values

I'm practicing loops in Python and started trying to have a better approach with user inputs, is there better ways of dealing with inputs when coding? And I tried using deques too, it worked very well,...
• 141
1 vote
264 views

### Deque implementation using Arrays in C++

I have written code for the basic implementation of a Deque in C++ using Array(pointer). Please review my code and suggest ways to make it simpler, compact, and efficient. Also would appreciate ...
• 143
2k views

### Deque class for .Net (C#)

As .Net has no Deque class (Double-Ended Queue) in the Frameworks and I couldn't find an example implementation that I was happy with, I have written the following with the intent that I may post it ...
• 205
402 views

### Optimize Leetcode 239. Sliding Window Maximum using Swift

LeetCode problem 239. Sliding Window Maximum You are given an array of integers nums, there is a sliding window of size k which ...
• 253
153 views

### Python list subclass with O(1) prepend / How to get bisect to work with reverse sorted list

For a particular problem, I need to have a list that: supports O(1) prepend, and that I can call bisect.bisect_left on, which ...
• 456
1 vote
149 views

### How to create a maze solve search with BFS provide navigation movements

How should I structure this code to create a maze, solve it with breath-first-search (BFS) and to provide basic navigation movements by 1 step within maze with number of moves required to navigate? ...
• 11
216 views

### Faster, indexed, heuristic doubly-linked list data structure in Java: implementation

I have this doubly-linked list data structure that runs all the single-element operations in $\Theta(\sqrt{n})$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
• 28.7k
195 views

### Another Sliding Window - find each k-size window the maximum num. from an integer array/list

I've searched this site and find many similar questions, but not exactly the same as the one I'll post. This attempts to solve Leetcode 239: You are given an array of integers ...
• 188
332 views

### Deque class in Common Lisp

I created a library with two CLOS class to implement a deque structure similar to the one available in C++, plus a few Lisp-ian twists. The two classes are node, ...
• 163
5k views

### A simple thread-safe Deque in C++

I am trying to implement a thread-safe deque in C++. ThreadSafeDeque will be used by a FileLogger class. When threads call the <...
• 255
1 vote
2k views

### Deque implementation with array in Java

I'm trying to implement a deque data structure with an iterator in Java using array. Please help to review and point out things that I can improve on. ...
1 vote
3k views

### Deque implemented using a circular array

I found a tutorial on implementing a deque using a circular array. I changed the implementation but I am not sure if it is correct or not. So I have one question: I wrote code that uses an ...
• 111
823 views

### A deque for up to one million elements

I have a task where I need to write my own deque and to this code was executed for 1 second, I get a result of 1.09 sec. The max count of elements is 1000000. How can I optimize it for better ...
1k views

### Linked deque implementation in C

I wrote a deque implementation in C for storing char *. It uses a doubly linked list, but I'm calling it a deque since it can only push/pop from the head and tail ...
• 151
1 vote
3k views

### Deque using doubly linked list

I was trying to implement a deque using a singly LL when I realized that eject() (popping the tail element) wasn't going to work without a pointer to the previous ...
• 1,139