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.
If I'm reading it correctly, it's basically saying:
If deque does not contain the element that we just removed (which implies that it's not there at all any more), we remove it from the set. The alternative, if deque still contained an element after we removed it, that would mean that there were at least two of those element in the sub-array, and so we have at least one left over. Therefore, it should still be considered part of the 'set'.
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 →
If I'm reading it correctly, it's basically saying:
If deque does not contain the element that we just removed (which implies that it's not there at all any more), we remove it from the set. The alternative, if deque still contained an element after we removed it, that would mean that there were at least two of those element in the sub-array, and so we have at least one left over. Therefore, it should still be considered part of the 'set'.