Thursday, December 26, 2013

SPOJ 9788. Friends of Friends

Here is the problem statement
http://www.spoj.com/problems/FACEFRND/

Some commets that you can use STL set to solve, of course its a good choice but we can do it in a simpler way(without using STL). Just because the numbers are 4 digit numbers , we can just keep a boolean array , and every time we read a number A (the number of a friend's friend) we mark Mark[A] as true. Then at the end we loop from 1000 to 9999 and calculate the number of marked spots. Its is shorter when you are using STL but this way is safer :) .

       DOWNLOAD THE FULL SOURCE CODE

No comments:

Post a Comment