Doubt in the logic

Can you tell why the erase function is giving error?

hello @vageesha

u have Already erased 2 , and in last line u r again trying to erase 2 which is now not present because of that it is giving seg fault.
the iterator it is now invalid after the 2 is erased

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.