In your inset method why do you do
return map[val].size() == 1 ? true : false;
when you could just do
return map[val].size() == 1;
@kevin36 Oh...my bad. Yes, totally agree with you. Thanks for pointing out!
@haruhiku No problem, it happens to all of us at times.
In remove, what if val==vec.back() ?
Then you just erase the last element, push in another already existing element, and delete this one. You have to make sure they are the same one, or your will delete twice.
@dfnjy Have fixed it, should work now. Thanks :)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.