GeeksforGeeks » Algorithms
Delet negative elements from a queue
(3 posts)-
write an algo that deletes all negative integers without changing the order of remaining elements of the queue
-
If we know the size of queue then following solution is fine.
deque a element if +ve enque again if(-ve) do nothing
What if we don't know the size?
-
I think we can store the address of 1st positive element found and then keep on checking if that address is found again, if it is found then we stop.
Reply
You must log in to post.