Of course there will be differences. The first version creates a new set for each iteration of the inner loop, whereas the second version will create a single set for each iteration of the outer loop.
To put it another way: the second version will create a set that will be shared between all iterations of the inner loop, whereas the first version creates a new set each time, and all data added to the set will be lost. I can't tell for sure without seeing the rest of the code, but it's almost certain that one of the two versions is wrong (it all depends on what you actually want to do.)