GeeksforGeeks » Algorithms

Delet negative elements from a queue

(3 posts)
  1. suraj
    guest
    Posted 11 months ago #

    write an algo that deletes all negative integers without changing the order of remaining elements of the queue

  2. suraj
    guest
    Posted 11 months ago #

    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?

  3. mAc
    guest
    Posted 11 months ago #

    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.

RSS feed for this topic