Here are two codes for question- Your text to link here...
code 1-Your text to link here...
code 2-Your text to link here...
In code 1 iterator is erased first and dereferenced after that.(Runtime error at test 39).
In code 2 iterator is dereferenced first and erased from set after that.(Accepted)
If code 1 is wrong practice why it got accepted for 38 test cases?