Thursday, February 6, 2014

SPOJ 13002. For Loops Challenge

The problem statement

This task is an implementation task and the biggest challange is the output format. But anyway I will explain how to solve it in case you need an explaination. I think the best way would be getting all the elements in one array and sort them . Then we need to loop and with that we will keep 2 numbers p and q, which shows the interval which is going to be printed. If the difference between teh current element and the next element equals to 1 then we increment q with 1 if not then we write the output which tells that the number between A[p] and A[q] are printed then we turn the values p and q to the next index. Check the source code for a better understanding.


       DOWNLOAD THE FULL SOURCE CODE

No comments:

Post a Comment