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.
Test cases. 1-8 work fine. 9 and 10 are timing out. Any leads to find the issue ?
My approach :-
Populate a deque with entire input.
Create a subArray of size m and populate it by polling front of queue.
Check unique in the subArray and update maxUnique counter if greater than previous maxUnique.
Left Shift each array value by 1 except the last(m-1) and poll the front of deque for 1 element and copy to end of array.(subArray[m-1] = headOfDeque).
So I iterate the deque only once.
It still times out.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Dequeue
You are viewing a single comment's thread. Return to all comments →
Test cases. 1-8 work fine. 9 and 10 are timing out. Any leads to find the issue ?
My approach :- Populate a deque with entire input. Create a subArray of size m and populate it by polling front of queue. Check unique in the subArray and update maxUnique counter if greater than previous maxUnique. Left Shift each array value by 1 except the last(m-1) and poll the front of deque for 1 element and copy to end of array.(subArray[m-1] = headOfDeque). So I iterate the deque only once. It still times out.