Skip to main content

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.

Filter by
Sorted by
Tagged with
4 votes
2 answers
331 views

C++ Deque Implementation

Took a shot at implementing std::deque in C++. I aimed for amortized O(1) push_front and <...
jdav22's user avatar
  • 361
4 votes
2 answers
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, ...
user274177's user avatar
3 votes
1 answer
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,...
eddyxide's user avatar
  • 141
1 vote
1 answer
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 ...
Ultimate's user avatar
  • 143
3 votes
1 answer
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 ...
RBarryYoung's user avatar
3 votes
2 answers
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 ...
Shawn Frank's user avatar
0 votes
2 answers
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 ...
joseville's user avatar
  • 456
1 vote
0 answers
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? ...
Matthew's user avatar
  • 11
2 votes
1 answer
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 ...
coderodde's user avatar
  • 28.7k
4 votes
1 answer
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 ...
Daniel Hao's user avatar
3 votes
1 answer
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, ...
Paulo Mendes's user avatar
8 votes
2 answers
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 <...
Andy's user avatar
  • 255
1 vote
1 answer
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. ...
CaRtY5532's user avatar
1 vote
3 answers
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 ...
beehuang's user avatar
  • 111
4 votes
3 answers
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 ...
Denis Steinman's user avatar
5 votes
2 answers
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 ...
LT_'s user avatar
  • 151
1 vote
1 answer
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 ...
jeremy radcliff's user avatar
4 votes
2 answers
8k views

Implementation of std::deque

In the prior obsolete implementation of std::deque, I used two std::vectors to contain the elements. But the standard guarantees that pointers and references to elements aren't invalidated when an ...
Dannyu NDos's user avatar