Algorithm of 10935 - Throwing cards away I

Problem Description Link
Algorithm:

This is a simple problem just use queue.
Algorithm:
1. get input 1 to n in queue
2. loop until queue not empty

last=front element of queue
               pop front element
            if(queue not empty)
print front element of queue
                push front element of queue in queue
pop front element
3. print last for remaining element.
4. end
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience