Well, thats done on purpose. This is because Set A is superset of Set B and i need to first find the begin element of set B in set A and then start looking for missing elements in Set B.

Example:

Set A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Set B = {3,4,7,9,10}

The output required is: 5, 6, 8 and NOT 1, 2, 5, 6, 8. This is because Set B "begins" from 3. However, both sets have same end elements - 10.

I think the set-difference mentioned before also lands me in same problem.

Also is there a way to "free" iterators like how we delete/free pointers in C++?

Thanks;
Labhesh.