We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This works but is much less efficient compared to using the Counter class. List's remove() method has to do a sequential scan through the list in order to find the element to remove, while the Counter class can almost instantly find it by calculating a hash value.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
collections.Counter()
You are viewing a single comment's thread. Return to all comments →
This works but is much less efficient compared to using the Counter class. List's remove() method has to do a sequential scan through the list in order to find the element to remove, while the Counter class can almost instantly find it by calculating a hash value.