We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You can exploit the constraints to have a 1-to-1 mapping for maintaining frequency, to get a constant time contains result. Here's my most optimized code for this. Also, intializing the Deque and Set to a fixed size helps performance by eliminating resizing, and rehashing.
Java Dequeue
You are viewing a single comment's thread. Return to all comments →
You can exploit the constraints to have a 1-to-1 mapping for maintaining frequency, to get a constant time contains result. Here's my most optimized code for this. Also, intializing the Deque and Set to a fixed size helps performance by eliminating resizing, and rehashing.